Function Procedures Sub-Procedures in VB Scripts with QTP



Function Procedures Sub-Procedures in VB Scripts with QTP

In this session let's talk about the user defined procedure.
Procedure are the group or set of executable statement.

So VBScript, support the following two types of procedures:-
  1. Sub Procedures
  2. Function Procedures

Sub – Procedures: The series of VBScript statements are called Sub Procedures, These were enclosed by Sub and end Sub statement which execute the action but never return any value. A sub procedure also can take parameters or arguments. If it didn't have any parameter then it definitely have the empty parenthesis ().

So now following provided procedure using built – in, VB Script functions, two intrinsic, MsgBox and InputBox, to prompt a user for more info. The result will displayed by them on the based of provided information calculation. All this calculation will be performed inside the code given in this sub procedure. Following is one good example of Procedure():

Sub ConvertTempt()
tempt = InputBox(“Please input the temperature in degrees F.”, 2)
MsgBox “The temperature is ” And Celsius(tempt) & ” degrees Celsius.”
End Sub

Function Procedure:
The VB Script statements enclosed by the Function and end function statement are called Function Procedures. This function procedure is just like a sub procedures but it can return the required value on the calling of that function mean we can call it any other function and can retrieve value from it. Function property can take or accept the argument or parameters. As the VB Script have only one type of data type so function always return only variant type of values.

Following Example shows the - the Celsius function calculate degrees Celsius from the degree Fahrenheit. When the function is called from the ConvertTempt Sub procedure, a variable containing the parameters values are passed to the functions. The result of the calculation will return to the calling procedures and displayed the result in a coded message box .


Sub ConvertTempt()
tempt = InputBox("Please input the temperatures in degrees F.", 2)
MsgBox "The temperature is " & Celsius(tempt) & " degrees C."
End Sub Function Celsius(fDegrees)
Celsius = (fDegrees - 32) * 5 / 9
End Function


Some Tips About the Function and Su-Procedures:
Function Procedures






Advantages and Disadvantages of Automation Testing













Use of add-ins
Cookies in QTP


What is Object Spy in QTP Ordinal Identifiers Alone can Make an Object Unique



Test Automation Frameworks Types




MOBILE APPS    QTP TESTING QUESTIONS  MANUAL TESTING  ANDROID APPS


No comments:

Post a Comment

Popular Posts