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

Give me detailed theritical explanation about keyword driven, hybrid framework, environment variables, hybrid frame work

0 Answers   TCS,


If you entered into yahoo mail with your valid user name and password , then you will get " welcome , username " (for example you will see , “welcome, Krishna” ) text on the top of the Inbox page , how can you test the user name is correct or not using QTP?

3 Answers   CTS,


when there is a task that gets repeated in multiple scripts what do you do in QTP?

2 Answers   Ordain Solutions,


In a flight window we have to enter the name and meal request for every passenger.In that window if we give Total passengers=1 then the Psngr1 name field and psngr1 meal request field will reflects.if we give Total passengers=2 then Psngr1 name field and psngr1 meal request field,Psngr2 name field and psngr2 meal request field and so on. how we can handle this scenerio thru Descriptive programming?

0 Answers  


interviwer asks what is data table? my ans is Data table is an internal Excel file of QTP...intervier not happy with this also? can u post any other answer?

3 Answers   Accenture,






Hi guys, Our company has started to automate testing and started using the tool QTP.Iam new to QTP and I have the following questions to ask. Would appreciate if anyone could give me a hand on this and explain things in a detailed way. [1] Bugs outside checkpoints: I know that I can easily make the QTP do what I want inside the application. Also, I know that I can insert some checkpoints and that the qtp will notice if those conditions are not met. However, there are bugs and problems that might not be connected to a checkpoint (system crash, database error, losing session/logout etc.); how can I make sure that the QTP will notice such problems as well and flag a test as failed. [2] How to tell the QTP that when a particular statement is "false",it should flag it as, test failed and show in in the test report. In short how to tell the qtp that a test is false from the script so that it shows it in the report For Eg:- if(true) test passed // how to instruct qtp else test failed // how to instruct qtp [3] Test script portability: we are having several environments; If I record a test on User Interface, obviously, the qtp will save the URL; however, how can I make the qtp run the tests so that the url is provided dynamically. Is there a possibility to parameterize the web server.Is this the way to do it.I dont know? [4] Test management: How do I manage the tests? I guess we will be doing it in Quality Center, yet, it’s not perfectly clear to me how we will be doing that. [5] Running scheduled test sets: How do I group tests to a certain test set? How can I make this test set run at a predefined time? [6] Test maintenance: What do we need to do beforehand in order to enable for easy test maintenance, meaning small adjustments in tests? [7] Reports: What kind of reports on test results are available (either QTP or Quality Center)? Thanks in advance and hoping for an answer. Jen

0 Answers  


what is the abbrivation of .mtr in action reposirtory?

8 Answers   GE,


How to export(copy) the entire webtable from the webpage into Excelsheet? using Vb scripting

9 Answers  


How do you done Data-Driven Testing using MS-Word. What is the script for that

3 Answers   IBM,


Explain about Table and DB Checkpoints?

1 Answers   Crea,


Can we directly start working with QTP without any knowledge on WinRunner? (After getting trsining on QTP)

1 Answers  


How QTP recognizes Objects in AUT?

1 Answers   Crea,


Categories