Sub and Functions are used to write a common code that can be called many times in a programm in QTP.
Difference between Sub and Function is that We can return a value from a function but In sub it is not possible to return value.
Example -
Sub mysub(b)
a= 8*b
print a
End Sub
Public Function RandomCharacters(CharLength)
str = ""
intHighNumber = 90
intLowNumber = 65
Randomize
For i = 1 to CharLength
RdNumber = Int((intHighNumber - intLowNumber + 1) * Rnd + intLowNumber)
stch = chr(RdNumber)
str = str&stch
Next
Reporter.ReportEvent micPass,"Random Character Generated","Random Character "&str&" was generated"
RandomCharacters = str 'return a value from function
End Function
No comments:
Post a Comment
Please Leave your reply. We value your feedback and inputs