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

ACTUALLY I AM WORKING IN THE DISTRIBUTION DOMAIN.MY COMPANY IS PROVIDING DISTRIBUTION SOFTWARE FOR PHARMA AND FMCG DISTRIBUTORS.HERE I AM USING QTP 9.2.HERE IN MY APPLICATION WHILE RECORDING ONE WINDOW APPEARS.IN THAT I CAN SELECT THE ITEM OR NO NEED TO SELECT.BUT WHILE RUNNING THE SAME SCRIPT THE WINDOW MAY NOT APPEAR OR APPEAR.HOW TO WRITE SCRIPT FOR THIS

0 Answers  


Can I do Game testing with QTP tool

1 Answers   Google,


what is the difference between data driver & data driven and driver script?

0 Answers  


suppose im having a string wipro123xyz i need to get the value 123 only from the string today 123 will be in the middle from tommorow it will be changing to front or back how to get the no if it changes continously?

2 Answers   Wipro,


can the activities of test case design be automated?

0 Answers  






Explain about reusable actions?

3 Answers   IBM,


What is the use of Testing framework in Automated testing..what are different kinds of Testing frameworks available in Automated testing...

1 Answers   IBM,


what is meant by source control?

0 Answers   Ordain Solutions,


Can we put more than one action in a single script???? yes or no.....

2 Answers   BirlaSoft,


How to change the priorities of the recovery scenario properties?

0 Answers  


what is aregular expression?

4 Answers   UHG,


Can we select add ins in UFT during run time

1 Answers   NIIT,


Categories