Input Box function

Input Box function

Input box function is used to retrieve a input from the user

Parameters
The input box function takes three parameters:

InputBox PromptText, DialogTitle, DefaultText

The PromptText is a string containing the text to be displayed as the prompt. The DialogTitle is a string containing the text to be displayed in the dialog’s title, and DefaultText is a string containing the text to be already displayed in the text box.

Description

The code below displays the dialog box

InputBox “Please enter the name”,”Enter Name”, “Michael”

However, we need to know what the user entered! The InputBox function returns a string, which is the text the user entered in the Input Box.

Dim Name As String
Name = InputBox (”Please enter the name”, _
                  “Enter Name”, “Michael”)
Msgbox “The name is ” & Name

This displays an input box asking the user for a name. When the user clicks OK then a Message Box will be displayed showing the text the user entered. You will notice that if you press cancel, the message box is still displayed. When the cancel button is pressed, the InputBox returns an empty string. You can edit the code so the message box is not displayed if the user presses cancel, or does not type anything:

Dim Name As String
Name = InputBox (”Please enter the name”, _
                  “Enter Name”, “Michael”)
‘ If Name is not empty, display the message box
If Not Name = “” Then Msgbox “The name is ” & Name

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.