what is the difference between function and subroutine
....here every one knows theoretically...here my QUESTION IS
WHAT IS THE MEANING OF FUNCTION CAN RETURN A VALUE AND SUB
CAN NOT RETURN A VALUE .....WHAT DOE'S IT MEAN FUNCTION CAN
RETURN A VALUE HOW FUNCTION CAN AND SUB CAN'T ....GIVE A
EXAMPLE FOR BOTH ....HOW IT CAN AND CAN NOT...HELP ANDY ONE....



what is the difference between function and subroutine ....here every one knows theoretically...her..

Answer / denis parker

Function - can return value (but not must) to the calling script

Function with argument and not return value
x = "10"
y = "12"
Call Addition_1(x, y)
Function Addition_1(x, y)
msgbox (x&y)
End Function

Function without argument and not return value
Call Addition_2()
Function Addition_2()
x = "10"
y = "12"
msgbox (x&y)
End Function

Function with argument and return value
x = "10"
y = "12"
z = Addition_1(x, y)
Msgbox z
Function Addition_1(x, y)
Addition_1 = (x&y)
End Function

Function without argument and return value
z = Addition_1()
Msgbox z
Function Addition_1()
x = "10"
y = "12"
Addition_1 = (x&y)
End Function


Subroutine - cannot return value to the calling script

Subroutine with argument and not return value
x = "10"
y = "12"
Call Addition_1(x, y)
Sub Addition_1(x, y)
msgbox (x&y)
End Sub

Subroutine without argument and not return value
Call Addition_2()
Sub Addition_2()
x = "10"
y = "12"
msgbox (x&y)
End Sub

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More QTP Interview Questions

How to make arguments optional in a function?

0 Answers   Crea,


What is checkpoint in qtp?

0 Answers  


I have below user Defained function function AddTwo(ByVal a, ByVal b) Dim Ans Ans=a+b MsgBox Ans End function Now my question comes here...from given below methods which method is right to call above function?Which is Wrong and why? 1. AddTwo(2,4) 2. Call AddTwo(2,4) 3. AddTwo 2,4 4. Call AddTwo 2,4

1 Answers  


How can you merge two Object Repositories?

3 Answers  


How many scripts do you write per day. What is the average number of scripts you have written in your recent project

1 Answers   CenturyLink, Optum, Value Labs,






what is the purpose of .vbs file?

2 Answers   HCL,


hi i have one issue while coding the dates . i want to add the date curret to 4 days . can any one helme plz about this regards balaji

2 Answers  


What is the entry and exit point of automation testing

2 Answers   Infosys,


To which environments does quicktest professional supports?

0 Answers  


how to handle the textboxes where in it should take the sum like ex:: while posting a question in this site it will for what is the result of 6+3=__ where in we have to enter manually 9 and click on submit... but how to handle these cases in qtp.. can someone plz help me out wid dis...

1 Answers  


what is the diff b/w assistive and mandatary rules of object repository in QTP???

0 Answers  


How to execute a winrunner script in quicktest professional?

0 Answers  


Categories