Use an empty variable instead of ""
Uninitialized variables are set to a special value: empty. When empty is cast to a string it becomes "".
Contrived example (using z instead of ""):
s=InputBox(z)
For i=1To 5
For j=1To i
r=r&s
Next
MsgBox r
r=z
Next
For numeric types Empty is 0, and for booleans it is false. This can cut down on initialization code.
a=inputbox("Enter Starting Value")
b=a
while done=0
i=i+1
b=b*2
done=(b>10000 or i>10)
wend
msgbox "Your "&a&" rabbit(s) have turned into "&b&" rabbit(s) in "&i&" years."
My friends would like this :) – ckjbgames – 2017-03-29T01:41:29.190
Just in case anyone is editing vbs in notepad and just running the file - you can save yourself from having to see lots of
MsgBox
s by replacing theMsgBox
s withWScript.Echo
s and running the VBScipt file in cmd.exe with CScript (CScript C:\filepath\file.vbs
) – Taylor Scott – 2018-01-25T04:30:20.220Oh and you can add syntax highlighting for VBScript (or any VB derivative) using the markdown notation
<!-- language-all: lang-vb -->
– Taylor Scott – 2018-01-25T04:32:54.270