Thursday, January 3, 2019


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 inte




Related Posts:

  • Date time functions in vb script Date time functions in vb script It is very important that you know how to work with date and time in VBScript as most of the VBScript programs will have date and time involved in it.Below is the list of all date and … Read More
  • What are the different operators in vbscript? What are the different operators in vbscript? At broad level there are 3 kinds of operators as mentioned below. Arithmetic Operators Comparison Operators Logical Operators Arithmetic Operators in the order of pre… Read More
  • Error handling in VBScript Error handling in VBScript VBScript provides below statements and keywords to handle errors. on error resume next Err object - err.description, err.number Sample code to handle the error is given below If er… Read More
  • Classes in VBScript Classes in VBScript Here is an example that shows how we can create a class in QTP. Once we define the class, we can create its objects and then access its method and properties. 'declare the class book. Class Bo… Read More
  • Data Types in vbscript Data Types in vbscript In vb script all variables are initialized with the data type called variant. But we can have below sub-types in vb script. In below table we have mentioned all sub data types in vb sc… Read More

0 comments:

Post a Comment

Blog Archive

Translate

Popular Posts

Total Pageviews

151,668

Blog Archive