GetString 方法 (ActiveX)
从用户获取字符串。 支持的平台:仅限 Windows 签名VBA: RetVal = object.GetString(HasSpaces [, Prompt])
返回值 (RetVal)类型:字符串 从用户返回的字符串。 言论AutoCAD 暂停用户输入字符串,并将结果设置为用户输入的字符串。HasSpaces 参数指定字符串是否可以包含空格。Prompt 参数指定此方法在 AutoCAD 暂停之前显示的字符串。 AutoCAD 用户可以从键盘输入字符串。如果 HasSpaces 参数为 True,则字符串可以包含空格,用户必须通过输入 [Return] 来终止它。如果 HasSpaces 为 False,则输入空白或 [Return] 将终止字符串。如果用户输入的字符超过 132 个字符,则字符串输入将继续进行,直到用户输入空格或回车符(根据 HasSpaces),但仅将前 132 个字符放入返回值中。GetString 例子VBA: Sub Example_GetString() ' This example demonstrates different ways of returning a string ' entered by a user. AppActivate ThisDrawing.Application.Caption Dim returnString As String ' Prompt & Input cannot contain blanks returnString = ThisDrawing.Utility.GetString(False, "Enter text (a space or terminates input): ") MsgBox "The string entered was '" & returnString & "'", , "GetString Example" ' Prompt & Input can contain blanks returnString = ThisDrawing.Utility.GetString(True, "Enter text ( terminates input):") MsgBox "The string entered was '" & returnString & "'", , "GetString Example" ' Prompt & Input can contain blanks, but not an empty string Dim NoNull As Integer NoNull = 1 ' Disallow null ThisDrawing.Utility.InitializeUserInput NoNull returnString = ThisDrawing.Utility.GetString(True, "Enter text ( terminates input): ") MsgBox "The string entered was '" & returnString & "'", , "GetString Example" End Sub 可视化 LISP: (vl-load-com) (defun c:Example_GetString() ;; This example demonstrates different ways of returning a string ;; entered by a user. (setq acadObj (vlax-get-acad-object)) (setq doc (vla-get-ActiveDocument acadObj)) ;; Prompt & Input cannot contain blanks (setq returnString (vla-GetString (vla-get-Utility doc) :vlax-false "Enter text (a space or <enter> terminates input): ")) (alert (strcat "The string entered was '" returnString "'")) ;; Prompt & Input can contain blanks (setq returnString (vla-GetString (vla-get-Utility doc) :vlax-true "Enter text (<enter> terminates input):")) (alert (strcat "The string entered was '" returnString "'")) ;; Prompt & Input can contain blanks, but not an empty string (setq NoNull 1) ;; Disallow null (vla-InitializeUserInput (vla-get-Utility doc) NoNull) (setq returnString (vla-GetString (vla-get-Utility doc) :vlax-true "Enter text (<enter> terminates input): ")) (alert (strcat "The string entered was '" returnString "'")) ) |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2024-12-15 11:38
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.