jon
jon

Reputation: 953

VBscript print value from input box to file

How can I print the NUM value that I get from the input box in to the file? (because I get in the file "NUM" and not the value of the NUM

NUM=InputBox("ENTER NUM")
.
.
.

CreateNewFile.Write ("add this line in file with NUM")

Upvotes: 0

Views: 2713

Answers (1)

Cody Gray
Cody Gray

Reputation: 244981

It looks to me like you're putting NUM in quotation marks. That's going to instruct the computer to print the literal value "NUM" instead of printing the value of the variable NUM.

Try this instead:

CreateNewFile.Write NUM

EDIT: Ahh, if you need to print a line of text preceding the value of the variable, then you will need to concatenate the two items. The way to do that in VBScript is to use the & operator:

CreateNewFile.Write "add this line in file with " & NUM

Notice how I've added the string literal in quotation marks, but then closed them before specifying the name of the variable? This instructs the computer that it should treat them as two separate entities. Otherwise, it has no way of knowing that NUM isn't just part of your string.

Upvotes: 1

Related Questions