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

Write the script to delete the mail which is at 9th,13th and 18th place in INBOX of Gmail ?

3 Answers  


What is the Test Object model in QTP?

3 Answers  


hi can anybody help with an qtp 9.2 license key please. Thanks, Nitesh.

0 Answers  


Object recognition in QTP is based on which model ? a) COM b) DCOM c) DOM d) None of the above

2 Answers   Ordain Solutions,


Browser("Las Vegas Hotels - Las").Page("Vegas Hotels - Hotels").Link("Luxor") ......here Luxor is a hotel and this is recognised as a link. I have many hotels like Luxor, Palms etc which are all displayed as link...How do I parametrize this by using webtable functions??? ASAP

1 Answers   HP,






This is a question thats generally asked in every QTP interview. What were the problems that you faced during automation and how did you resolve them?

0 Answers  


Use of Multiple Actions in QTP?

3 Answers  


Hi All, I am 4 yrs experieced in manual testing and new to automation tool QTP. Iam trying to learn it thru online and material i have.I am able to understand but unable to trace out which method or function to be used where necessary in VB Script. How come we know the functions or methods to be used to open a window when clicking on button or so...Pls suggest me.How can i proceed further to apt VB Script.

0 Answers  


What is creation time property and how does it work?

1 Answers  


IF we use batch testing.the result shown for last action only.in that how can i get result for every action.

2 Answers  


How to handle the exceptions using recovery scenario manager In QTP?

2 Answers  


What are the versions of qtp,What are the differences b/n them?

1 Answers   TCS,


Categories