PROBLEM TO BE SOLVED: To provide a measuring device and a program capable of reducing a possibility of decline in measuring accuracy of a subject having a corner part, a part of which is missing.SOLUTION: A reference line calculation unit 18c calculates a first edge reference line corresponding to an edge of a corner part of a subject having the corner part, a part of which is missing. A reference line calculation unit 18fd calculates a second edge reference line corresponding to the edge of the corner part. A point specification unit 18fb specifies points through which the second edge reference line passes. An angle specification unit 18fa specifies an angle, larger than 0 degrees and smaller than 180 degrees, in three-dimensional space, made by the second edge reference line with respect to the first edge reference line. A direction selection unit 18fc selects one of two directions that the second edge reference line can take depending on the specified angle. A size calculation unit 18fe calculates the size of the corner part, on the basis of three-dimensional coordinates corresponding to an intersection of the second edge reference line passing through the specified points and taking the selected direction, and the first edge reference line.