All the basic rules you should know about VbScript in the beginning. I recommend following along by trying this Vb Script either on the QTP/UFT software or make a .txt file, type in your code, and rename the .txt to .vbs :
Table of Contents
VbScript Syntax Rules:
The statements must fit onto one line; Example:
Dim x x = "you like mango donuts?" MsgBox x
Outputs:
Dim stands for dimension. To declare a variable, such as x, you type “Dim x”. Declaring a variable means that you are telling the Vb program that this variable exists. You can add more with addition signs, “Dim x+y+z” For example:
Dim x,y,z x = "you like mango donuts?" y = "you like tomatos?" z = "Do you like leafy?" MsgBox x+y+z
Outputs:
But if you don’t follow the rule that each statement must have it’s separate line, then you can run into an error; Example:
Dim x x = "you like mango donuts?" MsgBox x
Outputs:
What happened here is that MsgBox is not designed to do anything on it’s own, and the same holds true for variable x. That’s why you get an error. But if you combine the two on the same line then you are telling the Vb Script to make a dialog box (MsgBox) that shows the contents of variable x. Alternatively you can directly command Vb Script what to show:
MsgBox "Do you like Coconut Ice Cream?"
Outputs:
Continuing Vb Statement on Different Lines
But you can use an underscore to continue your vbScript on a separate line:
a=MsgBox("Joker's got Batman",_ vbAbortRetryIgnore +vbExclamation+vbDefaultButton2+vbSystemModal,"hello") If a=vbAbort then msgbox "quit",vbcritical
Output: