VBScript for Automation (QTP/UFT) Testing – Part 4

In VBScript – Part 4, let’s see the following topics:

String Functions
Date & Time

vbscript - part 4

STRING FUNCTIONS:

Let’s see the syntax and example of some of the important String Functions:

UCase:

Converts a specified string to uppercase

Syntax:

Example:

Lcase:

Converts a specified string to lowercase

Syntax:

Example:

Len:

Returns the number of characters of a string

Syntax:

Example:

Replace:

Replaces a specified part of a string with another string a specified number of times

Syntax:

Example:

Space:

Returns a string that consists of a specified number of spaces

Syntax:

Example:

Left:

Returns a specified number of characters from the left side of a string

Syntax:

Example:

Right:

Returns a specified number of characters from the right side of a string

Syntax:

Example:

Mid:

Returns a specified number of characters from a string

Syntax:

Example:

Trim:

Removes spaces on both the left and the right side of a string

Syntax:

Example:

LTrim:

Removes spaces on the left side of a string

Syntax:

Example:

RTrim:

Removes spaces on the right side of a string

Syntax:

Example:

StrReverse:

It reverses a string

Syntax:

Example:

InStr:

Returns the position of the first occurrence of one string within another

Syntax:

Example:

InStrRev:

Returns the position of the first occurrence of one string within another. The search begins at the last character of the string

Syntax:

Example:

StrComp:

Compares two strings and returns a value that represents the result of the comparison

Syntax:

Example:

Split:

It returns an array that contains a specific number of values split based on a delimiter

Syntax:

Example:

DATE & TIME FUNCTIONS:

Let’s see the syntax and example of some of the important Date & Time Functions:

Now:

Returns the current system date and time

Syntax:

Example:

Date:

Returns the current system date

Syntax:

Example:

Time:

Returns the current system time

Syntax:

Example:

DateAdd:

Returns a date to which a specified time interval has been added

Syntax:

Example:

DateDiff:

Returns the number of intervals between two specified dates

Syntax:

Example:

DatePart:

Returns the specified part of a given date

Syntax:

Example:

Day:

Returns a number that represents the day of the month

Syntax:

Example:

Month:

Returns a number that represents the month of the year

Syntax:

Example:

MonthName:

Returns the name of a specified month

Syntax:

Example:

Weekday:

Returns a number that represents the day of the week

Syntax:

Example:

WeekdayName:

Returns the weekday name of a specified day of the week

Syntax:

Example:

Year:

Returns a number that represents the year

Syntax:

Example:

Hour:

Returns a number that represents the hour of the day

Syntax:

Example:

Minute:

Returns a number that represents the minute of the hour

Syntax:

Example:

Second:

Returns a number that represents the second of the minute

Syntax:

Example:

TimeSerial:

Returns the time for a specific hour, minute, and second

Syntax:

Example:

TimeValue:

Returns a time

Syntax:

Example:

I would like to conclude VBScript – Part 4 here and will start VBScript – Part 5 in the next post.

VBScript Series:

VBScript for Automation (QTP/UFT) Testing – Part 1

VBScript for Automation (QTP/UFT) Testing – Part 2

VBScript for Automation (QTP/UFT) Testing – Part 3

VBScript for Automation (QTP/UFT) Testing – Part 4

VBScript for Automation (QTP/UFT) Testing – Part 5

Rajkumar SM is a founder of SoftwareTestingMaterial. He is a certified Software Test Engineer by profession and blogger & youtuber by choice. He has an extensive experience in the field of Software Testing. He writes here about Software Testing which includes both Manual and Automation Testing. He loves to be with his wife and cute little kid 'Freedom'.

Leave a Comment

Share via
Copy link
Powered by Social Snap