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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how to disable the pop ups through QTP using a script

1721


Describe synchronization point.

578


What is meant by Step generator?what is the use of this? we have 3 steps know there what r all those.? can u all pls give me clear idea of this

1402


am not having intrest in coding lang like c c++ java etc can i choose Testing tools as my carrier and please suggest me which tool is good (suitable for me)

1281


Discuss quicktest professional (qtp) environment?

577






What is the framework your company is following. What is the reason. Explain why key word driven frame work is chosen.

1628


please any one can explain the keyword driven framework. with gmail example.

1628


Mention the different actions types of qtp.

572


How is recording done when a application is over lapping the QTP application it gives a message object not recorded

1571


How to release all resources file from the QTP?

1053


Explain the terms test and business component?

547


In an interview, what r the general questions asked in SQL which is realted to testing ?pls give me anwser to this question?

1438


Difference between copy to action and call to action?

590


How to define array in qtp?

574


In qtp is it possible to check broken links of a page?

583