dcsimg
September 27, 2020
Hot Topics:

Basics of VB Programming

  • By Sam Huggill
  • Send Email »
  • More Articles »

The input box is a useful way of getting the user to input a string or other data type.

Input boxes can be called like this:

InputBox Prompt, Title, DefaultValue

The prompt is the same for the message box and so is the title, the default value can be left as blank if you don't want anything to appear. e.g.

InputBox "This is a test.","Title","Hi there!"

The InputBox always returns a string data type, so in some circumstances you may want to convert it to a number. To do this you can use the Val() function. e.g.

Val(InputBox("This is a test.","Title","9"

This would return the string value of 9 as an integer value.

You may want to check if the input from the user is nothing, or hasn't changed. e.g.

Dim sText
Dim sValue
sValue="Hi there!"
sText=InputBox("This is a test.","Title",sValue)
'Check for nothing
If sText="" Then Msgbox "No text"
'Check for no change
If sText=sValue Then Msgbox "No change."




Page 3 of 6



This article was originally published on November 20, 2002

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.


Thanks for your registration, follow us on our social networks to keep up-to-date