Monday, November 19, 2007

Functions in Test Partner

1)Right : Returns a Variant (String) containing a specified number of characters from the right side of a string.
Syntax : Right(string, length)
ex:dim k,str as string
str="foursoft"
k=right(str,len(str)-1)
msgbox k
Output :oursoft

2)Split: When we want a capture particular variable which is changing dynamically. Then instead of mid we can use split even if the variable is changing dynamically.
Syntax: Split (Variable,”Separator”)

Ex: Record Generated Sucessfully AP1023K
In This text I wanted to capture AP1023K
K= Record Generated Sucessfully AP1023K
In This text each word is counted as 1 variable and each one is taken into array count and an array is counted from ‘1’
K1=split (k,” “)
In the above text as Space is the separator we are taking space
Msgbox k1(4)
O/P - AP1023K

Suppose Ex:Record Generated Sucessfully : AP1023K
In the same example I have included ‘:’ before AP1023K
Then we can include separator as “:”
K1=Split(k,”:”)
Msgbox K1(1)
O/P - AP1023K

3)Mid : Returns a Variant (String) containing a specified number of characters from a string.
By using this statement we can get the exact value or character from a text area.
Syntax: mid (variable, position, length)

Ex Record generated successfully AP102KL3

To extract AP102KL3 into a variable we use this mid function

Dim k,k1
K=” Record generated successfully AP102KL3”
K1=mid (k,31,8)
Length of characters to be read.
Position of Required variable including count of space
Msgbox k1
O/P --- > AP102KL3

4) Now: Displays the current System Date and Time.
Ex: msgbox now
O/P= 04/01/2007 11:53A.M


i) If u want only present day then msgbox day(now)
O/p 04

ii) If u want only present month then msgbox month(now)
O/p 01

iii) If u want only present year then msgbox year(now)
O/p 2007

5)Date : To display only present system date

Ex : msgbox (date)
O/P = 04/01/2007
6)Time: To display only present system time.

Ex: msgbox (time)
O/P=12:02 P.M

No comments: