You are on page 1of 11

VBScript

Session 10

1
?What we learn last session
 Conversion Functions.
 Data Verification Functions.

2
Subjects for session 10
 VBScript string manipulation.
 VBScript string math.
 VBScript date manipulation.
 VBScript Formatting Strings.

3
VBScript string manipulation
 InStr - Returns the position of the first occurrence of one string within
another.
 InStrRev - Returns the position of an occurrence of one string within
another, from the end of string.
 Len - Returns the number of characters in a string or the number of bytes
required to store a variable.
 LCase - Returns a string that has been converted to lowercase.
 UCase - Returns a string that has been converted to uppercase.
 Replace - Returns a string in which a specified substring has been
replaced with another substring a specified number of times.
 Space - Returns a string consisting of the specified number of spaces.
 String – Returns a repeating character string of the length specified.
 StrReverse – Returns a string in which the character order of a specified
string is reversed.
 Trim, LTrim, RTrim - Returns a copy of a string without leading, trailing,
or both leading and trailing spaces.

4
VBScript string manipulation
 Left - Returns a specified number of characters from the left side
of a string.
 Right - Returns a specified number of characters from the right
side of a string.
 Mid - Returns a specified number of characters from a string.
 Join - Returns a string created by joining a number of substrings
contained in an array.
 Split - Returns a zero-based, one-dimensional array containing a
specified number of substrings.
 StrComp - Returns a value indicating the result of a string
comparison.
 Filter - Returns a zero-based array containing a subset of a string
array based on a specified filter criteria.

5
VBScript math manipulation
 Abs - Returns the absolute value of a number.
 Atn - Returns the arctangent of a number.
 Cos - Returns the cosine of an angle.
 Exp - Returns e (the base of natural logarithms) raised to a
power.
 Log - Returns the natural logarithm of a number.
 Sin - Returns the sine of an angle.
 Tan - Returns the tangent of an angle.
 Rnd - Returns a random number.
 Round - Returns a number rounded to a specified number of
decimal places.
 Sgn - Returns an integer indicating the sign of a number.
 Int, Fix - Returns the integer portion of a number

6
VBScript date manipulation
 Date - Returns the current system date.
 Time - Returns a Variant of subtype Date indicating the current
system time.
 Day - Returns a whole number between 1 and 31, inclusive,
representing the day of the month.
 Month - Returns a whole number between 1 and 12, inclusive,
representing the month of the year.
 MonthName - Returns a string indicating the specified month.
 WeekDay - Returns a whole number representing the day of the
week.
 WeekDayName - Returns a string indicating the specified day of
the week.
 Year - Returns a whole number representing the year.

7
VBScript date manipulation
 Hour - Returns a whole number between 0 and
23, inclusive, representing the hour of the day.
 Minute - Returns a whole number between 0
and 59, inclusive, representing the minute of
the hour.
 Second - Returns a whole number between 0
and 59, inclusive, representing the second of
the minute.
 Now - Returns the current date and time
according to the setting of your computer's
system date and time.

8
VBScript date manipulation
 DateAdd - Returns a date to which a specified time interval has
been added.
 DateDiff - Returns the number of intervals between two dates.
 DatePart - Returns the specified part of a given date.
 DateSerial - Returns a Variant of subtype Date for a specified
year, month, and day.
 DateValue - Returns a Variant of subtype Date.
 TimeSerial - Returns a Variant of subtype Date containing the
time for a specific hour, minute, and second.
 TimeValue - Returns a Variant of subtype Date containing the
time.
 Timer - Returns the number of seconds that have elapsed
since 12:00 AM (midnight).

9
.VBScript Formatting Strings
 FormatCurrency - Returns an expression
formatted as a currency value using the currency
symbol defined in the system control panel.
 FormatDateTime - Returns an expression
formatted as a date or time.
 FormatNumber - Returns an expression formatted
as a number.
 FormatPercent - Returns an expression formatted
as a percentage (multiplied by 100) with a trailing
% character.

10
Make sure to visit us
 Tutorials
 Articles
 Proikects
 And much more

www.AdvancedQTP.com

11