INPUTBOX$: Difference between revisions
Jump to navigation
Jump to search
Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link
No edit summary |
No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 22: | Line 22: | ||
{{PageAvailability}} | {{PageAvailability}} | ||
<!-- QB64 = a version or none, QBPE = a version or all, Platforms = yes or no --> | |||
<gallery widths="48px" heights="48px" mode="nolines"> | |||
File:Qb64.png|'''none''' | |||
File:Qbpe.png|'''v3.4.0''' | |||
File:Apix.png | |||
File:Win.png|'''yes''' | |||
File:Lnx.png|'''yes''' | |||
File:Osx.png|'''yes''' | |||
</gallery> | |||
<!-- additional availability notes go below here --> | |||
{{PageExamples}} | {{PageExamples}} | ||
; Example 1: Hello, | ; Example 1: Hello world, with common dialogs. | ||
{{CodeStart}} | {{CodeStart}} | ||
username$ = {{Cl|_INPUTBOX$}}({{Text|<nowiki>"Hello App"</nowiki>|#FFB100}}, {{Text|<nowiki>"Enter your name:"</nowiki>|#FFB100}}, {{Text|<nowiki>"anonymous"</nowiki>|#FFB100}}) | username$ = {{Cl|_INPUTBOX$}}({{Text|<nowiki>"Hello App"</nowiki>|#FFB100}}, {{Text|<nowiki>"Enter your name:"</nowiki>|#FFB100}}, {{Text|<nowiki>"anonymous"</nowiki>|#FFB100}}) | ||
Line 33: | Line 42: | ||
{{CodeEnd}} | {{CodeEnd}} | ||
; Example 2: Checking | ---- | ||
; Example 2: Checking whether the user cancelled the input dialog. | |||
{{CodeStart}} | {{CodeStart}} | ||
age$ = {{Cl|_TRIM$}}({{Cl|_INPUTBOX$}}(, {{Text|<nowiki>"Enter your age:"</nowiki>|#FFB100}})) | age$ = {{Cl|_TRIM$}}({{Cl|_INPUTBOX$}}(, {{Text|<nowiki>"Enter your age:"</nowiki>|#FFB100}})) | ||
Line 44: | Line 55: | ||
{{CodeEnd}} | {{CodeEnd}} | ||
; Example 3: Getting passwords | ---- | ||
; Example 3: Getting passwords. | |||
{{CodeStart}} | {{CodeStart}} | ||
password$ = {{Cl|_INPUTBOX$}}({{Text|<nowiki>"Login"</nowiki>|#FFB100}}, {{Text|<nowiki>"Enter password:"</nowiki>|#FFB100}}, {{Text|<nowiki>""</nowiki>|#FFB100}}) | password$ = {{Cl|_INPUTBOX$}}({{Text|<nowiki>"Login"</nowiki>|#FFB100}}, {{Text|<nowiki>"Enter password:"</nowiki>|#FFB100}}, {{Text|<nowiki>""</nowiki>|#FFB100}}) | ||
Line 57: | Line 70: | ||
{{PageSeeAlso}} | {{PageSeeAlso}} | ||
* [[_MESSAGEBOX]], [[_MESSAGEBOX (function)]] | |||
* [[_MESSAGEBOX]] | * [[_NOTIFYPOPUP]], [[_COLORCHOOSERDIALOG]] | ||
* [[_SELECTFOLDERDIALOG$]], [[_OPENFILEDIALOG$]], [[_SAVEFILEDIALOG$]] | |||
* [[ | |||
* [[_OPENFILEDIALOG$]] | |||
{{PageNavigation}} | {{PageNavigation}} |
Latest revision as of 14:03, 1 December 2023
The _INPUTBOX$ function displays a prompt in a dialog box, waits for the user to input text or click a button, and returns a string containing the contents of the text box.
Syntax
- result$ = _INPUTBOX$([title$][, message$][, defaultInput$])
Parameters
- title$ is an optional dialog box title.
- message$ is an optional message or prompt that will be displayed in the dialog box.
- defaultInput$ is an optional string that is displayed in the text box as the default response if no other input is provided.
Description
- Use message$ to specify instructions to the user.
- All parameters are optional, hence omitting defaultInput$ will display a empty text box.
- However, if defaultInput$ is provided, but is an empty string (""), then a password box is shown, and the text input will be masked.
- The result$ may be an empty string (""), if the user simply cancelled the dialog.
- The dialog box automatically becomes a modal window, if the application window is visible.
Availability
Examples
- Example 1
- Hello world, with common dialogs.
username$ = _INPUTBOX$("Hello App", "Enter your name:", "anonymous") _MESSAGEBOX "Hello App", "Hello " + username$, "info" |
- Example 2
- Checking whether the user cancelled the input dialog.
age$ = _TRIM$(_INPUTBOX$(, "Enter your age:")) IF LEN(age$) = 0 THEN _MESSAGEBOX , "Cancelled." ELSE _MESSAGEBOX , "Age = " + age$ END IF |
- Example 3
- Getting passwords.
password$ = _INPUTBOX$("Login", "Enter password:", "") IF LEN(password$) = 0 THEN _MESSAGEBOX , "Cancelled." ELSE _MESSAGEBOX , "You entered = " + password$ END IF |
See also
- _MESSAGEBOX, _MESSAGEBOX (function)
- _NOTIFYPOPUP, _COLORCHOOSERDIALOG
- _SELECTFOLDERDIALOG$, _OPENFILEDIALOG$, _SAVEFILEDIALOG$