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

what is the use of descriptive programming in QTP ? when we need to use DP? can we test the application completely with out useing DP?? please explan with example

2 Answers  


Explain about Table and DB Checkpoints?

1 Answers   Crea,


write a qtp script to verify that the business price is twice the economy price in flight reservation window

1 Answers  


How can i use virtual objects? If have i created one new virtual object in a virtual object manager by following instructions.

0 Answers  


Hello Everybody, Please tell me can we create Test Plan in QTP? This I am asking irrespective to integrating with Test Director.I mean is there any option to create Test Plan in QTP itself. Thanks, Gaytri

4 Answers  






Hi How to retrieve data from web element line by line?

0 Answers  


what is a file system object in QTP

7 Answers  


Hi all, In Every interview interview asking one question what type of challenges you have been faced in your project?

1 Answers  


Tell me the difference between the Data Driven Frame work and Keyword Driven frame work?

3 Answers   Semantic Space,


list me out the shortcutkeys for some functionlities in the qtp for example to record ,to run ... etc

2 Answers   CTS,


How many types of trigger events are there in qtp?

0 Answers  


how to test Web application using QTP software

0 Answers   Google,


Categories