CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

GetString Method (ActiveX)

2023-1-4 06:53| 发布者: admin| 查看: 682| 评论: 0|来自: AutoCAD

摘要: 从用户获取字符串。

从用户获取字符串。

支持的平台:仅窗口

签名

工 务 局:

RetVal = object.GetString(HasSpaces [, Prompt])
对象

类型:实用工具

此方法适用的对象。

哈斯空间

访问:仅输入

类型:

  • 0:返回字符串不能包含空格。它由回车或空格终止。
  • 1:返回字符串可以包含空格。它仅由回车终止。
提示

访问:仅输入;自选

类型:变体(字符串)

用于提示用户输入的文本。

返回值(RetVal)

类型:字符串

从用户返回的字符串。

言论

AutoCAD 暂停用户输入字符串,并将结果设置为用户输入的字符串。参数指定字符串是否可以包含空格。提示参数指定此方法在 AutoCAD 暂停之前显示的字符串。

AutoCAD 用户可以从键盘输入字符串。如果HasSpaces参数为 True,则字符串可以包含空格,用户必须通过输入 [Return] 来终止它。如果HasSpaces为 False,则输入空白或 [Return] 将终止字符串。如果用户输入的字符超过 132 个字符,字符串输入将继续,直到用户输入空白或回车符(根据HasSpaces),但仅将前 132 个字符放入返回值中。GetString

例子

工 务 局:

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

Visual 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 "'"))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-12 08:56

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部