Saturday 29 March 2014

Basic Syntax in VBScript

Basic VBScript Syntax
Remember below points about VBScript Syntax.
  1. VBScript is loosely typed language that means you do not need to declare the variables with data type
  2. VBScript comments start with symbol '. You can also comment using rem keyword.
  3. You do not need to put semicolon at the end of the statement like C,C++ and JAVA
VBScript also provides below functions that can be used to find out more information about the variables.

  1. IsArray - This function can be used to check if the given variable is an array or not
  2. IsDate - This function can be used to check if the given variable is a valid date or not
  3. IsEmpty - This function can be used to check if the given variable is empty or not
  4. IsNull - This function can be used to check if the given variable is a null or not
  5. IsNumeric - This function can be used to check if the given variable is valid number or not
  6. IsObject - This function can be used to check if the given variable is valid object or not
  7. TypeName - This function returns the data type of the given variable.
Examples - 


dim a(4)
dim b
b=10

Msgbox  "a is array? -> " & IsArray(a)     'prints true

Msgbox  "b is a date? -> " & IsDate(a)  'prints false

Msgbox  "b is empty? -> " & IsEmpty(b)  'prints false

Msgbox  "b is null? -> " & IsNull(b)   'prints false

Msgbox  "b is numeric? -> " & IsNumeric(b)   'prints true

Msgbox  "b is object? -> " & IsObject(b)   'prints false

Msgbox  "TypeName of b -> " & TypeName(b)   'prints integer

No comments:

Post a Comment

Total Pageviews