what's the difference in between function and sub and give
some code as well

Answers were Sorted based on User's Feedback



what's the difference in between function and sub and give some code as well..

Answer / kamesh

A Function procedure is a series of VBScript statements
enclosed by the Function and End Function statements. A
Function procedure is similar to a Sub procedure, but can
also return a value. A Function procedure can take arguments
a Function procedure has no arguments, its Function
statement must include an empty set of parentheses.

Function Celsius(fDegrees)
Celsius = (fDegrees - 32) * 5 / 9
End Function

A Sub procedure is a series of VBScript statements
(enclosed by Sub and End Sub statements) that perform
actions but don't return a value. A Sub procedure can take
arguments (constants, variables, or expressions that are
passed by a calling procedure). If a Sub procedure has no
arguments, its Sub statement must include an empty set of
parentheses ().

Sub ConvertTemp()
temp = InputBox("Please enter the temperature in degrees
F.", 1)
MsgBox "The temperature is " & Celsius(temp) & " degrees
C."
End Sub

Is This Answer Correct ?    8 Yes 0 No

what's the difference in between function and sub and give some code as well..

Answer / venkatesh

Hello every body,
If you don't know the rite example No issue...
But please don't copy and paste QTP user guide examples..
Humble request for all

Thanks
Venkatesh

Is This Answer Correct ?    4 Yes 2 No

what's the difference in between function and sub and give some code as well..

Answer / rachel wang

Nothing wrong to post a correct answer in any ways.

Of course 'QTP Online Help' provides the better answer, I
always look up QTP first.

- Rachel

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More QTP Interview Questions

If you giving priority as p0, as a developer if I give priority as p2, What happens In user defined function ?

0 Answers  


Hi Can u plz suggest who is the Best Faculty for Advanced QTP Scripting in Hyderabad ,plz suggest me..... or send me a replay to satheesh.goli@gmail.com, r make me a call 9866335752

1 Answers   AppLabs,


Give a comment on Regular Expressions using QTP?

4 Answers  


Does quicktest professional is unicode compatible?

0 Answers  


What is AUT in object reposity in QTP? Why we use it in Object repository???What is full form???????

6 Answers  






What type of problems one will face with QTP , if too many browsers are opened at a time?

2 Answers  


where exactly we can't do the automation testing. give some examples

2 Answers   Virtusa, Wipro,


Which object repository we use in real time and can we merge 2 object repostiory and how?

6 Answers   HCL, Satyam,


CAn anybody tell me how can I use QTP to capture any video in my application?I want to see the video file opened in my application after the tests are completed in tests results.Can anybody help me?

6 Answers  


What is the descriptive programming?

0 Answers  


What is the difference between keyword view and expert view?

0 Answers  


Can you tell me any books or websites to learn VB Script for QTP ??

1 Answers  


Categories