Gets an integer value from the user.
Supported platforms: Windows only
VBA:
RetVal = object.GetInteger([Prompt])
Type: Utility
The object this method applies to.
Access: Input-only; optional
Type: Variant (string)
The text used to prompt the user for input.
Type: Long
The integer value returned by the user.
AutoCAD pauses for user input of an integer and sets the return value to the selected value. The Prompt parameter specifies a string that AutoCAD displays before it pauses. The Prompt is optional.
The AutoCAD user can enter any valid (short) integer in the range of -32,768 to +32,767.
If a keyword is returned instead of an integer, or if the user presses Enter without entering a value, AutoCAD generates error number -2145320928 (and the error message, "User input is a keyword"). Use the GetInput method to obtain the keyword from the return value.
VBA:
Sub Example_GetInteger()
' This example returns the integer entered by the user.
AppActivate ThisDrawing.Application.Caption
Dim returnInt As Integer
' Return the value entered by user. A prompt is provided.
returnInt = ThisDrawing.Utility.GetInteger("Enter an integer: ")
MsgBox "The integer entered was " & returnInt & vbCrLf & _
"(Enter the next value without prompting.)", , "GetInteger Example"
' Return the value entered by user. No prompt is provided.
returnInt = ThisDrawing.Utility.GetInteger()
MsgBox "The integer entered was " & returnInt, , "GetInteger Example"
End Sub
Visual LISP:
(vl-load-com)
(defun c:Example_GetInteger()
;; This example returns the integer entered by the user.
(setq acadObj (vlax-get-acad-object))
(setq doc (vla-get-ActiveDocument acadObj))
;; Return the value entered by user. A prompt is provided.
(setq returnInt (vla-GetInteger (vla-get-Utility doc) "Enter an integer: "))
(alert (strcat "The integer entered was " (itoa returnInt)
"\n(Enter the next value without prompting.)"))
;; Return the value entered by user. No prompt is provided.
(setq returnInt (vla-GetInteger (vla-get-Utility doc)))
(alert (strcat "The integer entered was " (itoa returnInt)))
)