计算用户输入的两点之间的距离。
Sub 测量两点间的距离()
Dim point1 As Variant
Dim point2 As Variant
' 获取用户输入的点
point1 = ThisDrawing.Utility.GetPoint(, vbCrLf & "点击第一点: ")
point2 = ThisDrawing.Utility.GetPoint(point1, vbCrLf & "点击第二点: ")
' 计算 point1 和 point2 之间的距离
Dim x As Double, y As Double, z As Double
Dim dist As Double
x = point1(0) - point2(0)
y = point1(1) - point2(1)
z = point1(2) - point2(2)
dist = Sqr((Sqr((x ^ 2) + (y ^ 2)) ^ 2) + (z ^ 2))
'显示计算出来的距离
MsgBox "距离为: " & Left(dist, 5) & " mm", , "距离测量"
End Sub