Visual Basic Input Box

The InputBox( ) function can be used to accept keyboard input into a variable.

The basic format

variable = InputBox(“a prompt”, [”title”])

The prompt is displayed in a dialog box along with a text box for the user to enter the desired information. When the user clicks the OK button the value in the text box is return to the named variable. The value return must be the same data type as the receiving variable.

The statement

strguess = InputBox("enter a number", "Guessing Game")

 

Will display the following

image of inputbox

 

If the user chooses the Cancel button the function returns a null value.