嗨,凯文
,你可以做这样的事情:
- Public Function MeGetPointOrDistance() As Variant
- Dim aFstPnt As Variant
- Dim aNxtPnt As Variant
- On Error Resume Next
-
- With ThisDrawing.Utility
- aFstPnt = .GetPoint(, vbCrLf & "Select first point: ")
- If Err.Number 0 Then
- Err.Clear
- Exit Function
- End If
- aNxtPnt = .GetPoint(aFstPnt, vbCrLf & "Select next point/enter distance : ")
- If Err.Number 0 Then
- Err.Clear
- TestPnt = aFstPnt
- Else
- TestPnt = Sqr(((aFstPnt(0) - aNxtPnt(0)) ^ 2) + _
- ((aFstPnt(1) - aNxtPnt(1)) ^ 2) + _
- ((aFstPnt(2) - aNxtPnt(2)) ^ 2))
- End If
- End With
-
- End Function
- Use:
- Dim vRetVal As Variant
- vRetVal = MeGetPointOrDistance()
- Select Case VarType(RetVal)
- Case vbEmpty
- 'User pressed enter - do nothing
- Case vbDouble
- 'User had enter a distance
- Case Else
- 'User had enter a point
- End Select
|