• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Re: How to display a variable value in a dialog box and how to read user input?

  • Thread starter Richard Mueller [MVP]
  • Start date
R

Richard Mueller [MVP]

#1
Tony wrote:

> Sorry for this newbie question, but how do I display a variable value from
> a *.vbs script
> in a dialog box and - secondly - how to read a user input from a dialog
> entry field
> into a *.vbs script variable?
>
You can use the MsgBox function to display anything. You can concatenate the
value of a variable into a string to display. For example:
====
strValue = "Error"
strMessage = "Value of variable strValue: " & strValue & "."
Call MsgBox(strMessage, vbOKOnly + vbInformation, "My Script Title")
=========
Look up the MsgBox function in vbscript help. I run most scripts at a
command prompt using cscript. The MsgBox function pops up a box with the
message, but you can also echo to the command line with Wscript.Echo
statements. For example:
========
strValue = "Error"
strMessage = "Value of variable strValue: " & strValue & "."
Wscript.Echo strMessage
=======
To get input from the user, use the InputBox function. For example:
=====
strValue = InputBox("Enter a value", "My Script Title")
Wscript.Echo "The user entered the value: " & strValue
========
Again, check the help files for more syntax help, or search on "MsgBox" and
"InputBox".

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--
 

My Computer

Users Who Are Viewing This Thread (Users: 1, Guests: 0)