VB Script syntax rules and guidelines

VBScript Syntax Rules and Guidelines

1) Case-sensitivity:

By default, VBScript is not case sensitive and does not differentiate between upper-case and lower-case spelling of words, for example, in variables, object and method names, or constants.

For example, the two statements below are identical in VBScript:

Browser("Mercury").Page("Find a Flight:").WebList("toDay").Select "31"
browser("mercury").page("find a flight:").weblist("today").select "31"

2) Text strings:

When we enter a value as a text string, we must add quotation marks before and after the string. For example, in the above segment of script, the names of the Web site, Web page, and edit box are all text strings surrounded by quotation marks.

Note that the value 31 is also surrounded by quotation marks, because it is a text string that represents a number and not a numeric value.

In the following example, only the property name (first argument) is a text string and is in quotation marks. The second argument (the value of the property) is a variable and therefore does not have quotation marks. The third argument (specifying the timeout) is a numeric value, which also does not need quotation marks.

Browser("Mercury").Page("Find a Flight:").WaitProperty("items count", Total_Items, 2000)

3) Variables:

We can specify variables to store strings, integers, arrays and objects. Using variables helps to make our script more readable and flexible

4) Parentheses:

 To achieve the desired result and to avoid errors, it is important that we use parentheses () correctly in our statements.

5) Indentation:

We can indent or outdent our script to reflect the logical structure and nesting of the statements.

6) Comments:

We can add comments to our statements using an apostrophe ('), either at the beginning of a separate line, or at the end of a statement. It is recommended that we add comments wherever possible, to make our scripts easier to understand and maintain.

7) Spaces:

We can add extra blank spaces to our script to improve clarity. These spaces are ignored by VBScript.


Post a Comment