您可以使用该方法定义关键字或将输入类型限制为用户输入法。InitializeUserInput use 和参数值类似于 AutoLISP 函数。 可以与以下方法一起使用:、、、和。 不能与该方法一起使用。当用户输入法未返回字符串值时,使用该方法检索字符串值(关键字或任意输入)。initgetInitializeUserInputGetAngleGetCornerGetDistanceGetIntegerGetKeywordGetOrientationGetPointGetRealInitializeUserInputGetStringGetInput 该方法接受两个参数。第一个参数是位编码整数值,用于确定用户输入法的输入选项。第二个参数是定义有效关键字的字符串。InitializeUserInput 在AutoCAD命令提示符下从用户处获取整数值或关键字以下示例提示用户输入正数、非负整数值或关键字: Sub Ch3_UserInput() ' The first parameter of InitializeUserInput (6) ' restricts input to positive and non-negative ' values. The second parameter is the list of ' valid keywords. ThisDrawing.Utility.InitializeUserInput 6, "Big Small Regular" ' Set the prompt string variable Dim promptStr As String promptStr = vbCrLf & "Enter the size or (Big/Small/<Regular>):" ' At the GetInteger prompt, entering a keyword or pressing ' ENTER without entering a value results in an error. To allow ' your application to continue and check for the error ' description, you must set the error handler to resume on error. On Error Resume Next ' Get the value entered by the user Dim returnInteger As Integer returnInteger = ThisDrawing.Utility.GetInteger(promptStr) ' Check for an error. If the error number matches the ' one shown below, then use GetInput to get the returned ' string; otherwise, use the value of returnInteger. If Err.Number = -2145320928 Then Dim returnString As String Debug.Print Err.Description returnString = ThisDrawing.Utility.GetInput() If returnString = "" Then 'ENTER returns null string returnString = "Regular" 'Set to default End If Err.Clear Else 'Otherwise, returnString = returnInteger 'Use the value entered End If ' Display the result MsgBox returnString, , "InitializeUserInput Example" End Sub |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-1-8 19:03
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.