GetKeyword Method

AutoCAD ActiveX

 
GetKeyword Method
 
 
 

The GetKeyword method prompts the user for input of a keyword at the AutoCAD Command prompt. This method accepts only one parameter, which is the prompt string. The keywords and input parameters are defined with a call to the InitializeUserInput method.

Get a keyword from the user at the AutoCAD command line

The following example forces the user to enter a keyword by setting the first parameter of InitializeUserInput to 1, which disallows NULL input (pressing ENTER). The second parameter establishes the list of valid keywords.

Sub Ch3_KeyWord()
 Dim keyWord As String
 ThisDrawing.Utility.InitializeUserInput 1, "Line Circle Arc"
 keyWord = ThisDrawing.Utility.GetKeyword _
 (vbCrLf & "Enter an option (Line/Circle/Arc): ")
 MsgBox keyWord, , "GetKeyword Example"
End Sub

A more user-friendly keyword prompt is one that provides a default value if the user presses ENTER (NULL input). Notice the minor modifications to the following example:

Sub Ch3_KeyWord2()
 Dim keyWord As String
 ThisDrawing.Utility.InitializeUserInput 0, "Line Circle Arc"
 keyWord = ThisDrawing.Utility.GetKeyword _
 (vbCrLf & "Enter an option (Line/Circle/<Arc>): ")
 If keyWord = "" Then keyWord = "Arc"
 MsgBox keyWord, , "GetKeyword Example"
End Sub