NSB.InputBox: Difference between revisions

From NSB App Studio
Jump to navigation Jump to search
No edit summary
No edit summary
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[File:NsbInputBox.png|frame|iOS Style]]
[[File:NsbInputBoxAndroid.png]]
[[File:NsbInputBoxAndroid.png|frame|Android Style]]


NSB.InputBox(function, prompt[, title[, default]])
NSB.InputBox(function, prompt[, title[, default]])
Line 18: Line 17:
NSB.MsgBoxStyle=""  ' for iOS
NSB.MsgBoxStyle=""  ' for iOS
NSB.MsgBoxStyle="-android" 'for Android
NSB.MsgBoxStyle="-android" 'for Android
</pre>
To override the description in the buttons, do this:
<pre>
<pre>
NSB._["Cancel"]="Annuler"
NSB._["OK"]="D'accord"
</pre>


== Example ==
== Example ==

Latest revision as of 13:30, 12 February 2019

NSB.InputBox(function, prompt[, title[, default]])

Description

NSB.InputBox presents a modal dialog which prompts the user for an input value. While it is displayed, no other actions may be taken by the user. Unlike InputBox, this function does not halt the program: execution of the next statement will continue immediately. It will not wait for the user’s input. The advantage of this function is that title can be specified.

The function argument is the name of a subroutine or function in your program, which will be called when the control is dismissed. The prompt argument is required. It appears under the title. title is optional: if you do not specify one, the Title of the app will show. default is the initial value to show in the input field.

When the user clicks on OK or Cancel, function will be called with two parameters: the first one will be either vbOK or vbCancel, and the second one will be the value the user entered.

To dimiss an NSB.InputBox from your program instead of waiting for the user, call NSB.closeMsgBox().

The appearance of NSB.InputBox varies depending on whether it is running on an iOS or Android device. To override this, do

NSB.MsgBoxStyle=""  ' for iOS
NSB.MsgBoxStyle="-android" 'for Android

To override the description in the buttons, do this:

NSB._["Cancel"]="Annuler"
NSB._["OK"]="D'accord"

Example

Rem Demonstrate NSB.InputBox
Function Button1_onclick() 'InputBox
  NSB.InputBox(InputDone,"What am I thinking?", "InputBox Example", "Elephants")
End Function
 
Sub InputDone(result, value)
  If result=vbOK Then 
    TextBox1.value=value 
  Else 
    TextBox1.value="Cancel"
  End If
End Sub

Output

(If the user clicked on OK, the value entered will show in Text3.value. If the user cancelled,)

Related Items

InputBox