[求助]计算两点间距离,出错,代码是不是有问题
计算两点间距离,出错,代码是不是有问题Public Sub Ch2_CalculateDistance()
Dim Point1 As Vuarant
Dim Point2 As Vuarant
Point1 = ThisDrawing.Utility.GetPoint(, vbCrLf & "第一点:")
Point2 = ThisDrawing.Utility.GetPoint(Point1, vbCrLf & "第二点:")
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 "两点间的距离是:" & Dist
End Sub
Vuarant==>Variant
Dist = Sqr((Sqr((x ^ 2) + (y ^ 2)) ^ 2) + (z ^ 2)) 这是哪个爷教你的
Dist = Sqr(x ^ 2 + y ^ 2 + z ^ 2)
后面那个开平方多余,没有必要
本帖最后由 hkluck 于 2015-1-30 10:00 编辑zzyong00 发表于 2015-1-30 00:35
Vuarant==>Variant
Dist = Sqr((Sqr((x ^ 2) + (y ^ 2)) ^ 2) + (z ^ 2)) 这是哪个爷教你的
Dist = Sqr(x ...
额,是我自己打错的,没看到,谢谢哈,我调调 slide控件数组例子
页:
[1]