- Sub Example_GetInput()
- ' This example prompts for user input of a point. By using the
- ' InitializeUserInput method to define a keyword list, the example can also
- ' return keywords entered by the user.
-
- On Error Resume Next
-
- ' Define the valid keywords
- Dim keywordList As String, arrKL() As String, i As Long, flag As Boolean
- keywordList = "Keyword1 Keyword2"
- arrKL = Split(keywordList, " ")
- ' Call InitializeUserInput to set up the keywords
- ThisDrawing.Utility.InitializeUserInput 128, keywordList
-
- ' Get the user input
- Dim returnPnt As Variant
- returnPnt = ThisDrawing.Utility.GetPoint(, "Enter a point(Keyword1, Keyword2): ")
-
- If Err Then
- Debug.Print Err.Number
- If Err.Number = -2145320928 Then
- ' One of the keywords was entered
- Dim inputString As String
- Err.Clear
- inputString = ThisDrawing.Utility.GetInput
- For i = LBound(arrKL) To UBound(arrKL)
- If InStr(arrKL(i), inputString) > 0 Then
- flag = True
- Exit For
- End If
- Next i
-
- If flag Then
- MsgBox "You entered the keyword: " & inputString
-
- Else
- MsgBox "Error selecting the point: " & Err.Description
- Err.Clear
- End If
- End If
- Else
- ' Display point coordinates
- MsgBox "The WCS of the point is: " & returnPnt(0) & ", " & returnPnt(1) & ", " & returnPnt(2), , "GetInput 示例"
- End If
-
- End Sub
|