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

What are the challenges u faced in testing with crm domain? How u overcome with?

1456


How qtp identifies objects?

543


Can testing be done on the production system, or will a separate test system be required? How are browser caching, variations in browser option settings, dial-up connection variabilities, and real-world internet 'traffic congestion' problems to be accounted for in testing?

595


what is error and fault in terms of software quality?

1437


How to use output values in qtp ?

529






Explain in brief about the quicktest professional (qtp) automation object model?

535


Can you list some technologies that support qtp?

535


How can I import environment from a file on disk?

506


In QTP TEST DIRECTOR COMBINATION WHAT IS THE PURPOSE OF TEST DIRECTOR? In Somebody says to store test cases and design test cases.?ok fine , but In test director 5.0 , QTp not launching. what u do?

1469


How can you identify the browser and its information using the qtp script?

558


How can I check if a environment variable exist or not?

518


What is quicktest professional (qtp)?

540


how to write xml output check point bu useing descriptive programing .means without useing output check point

1618


i have to login into gmail loginpage i have to pass testcase into userid and password by using functions. the test case of user id is it should take only lowerletters alphabetin between 4 to 6 length.it should not take spectial letters.it should not take numbers.testcase for password is it should take numbers and it should not take alphabets note the following things must happen 1 when i give correct password and userid that password and userid should be seen in QTP result and notepad,xl sheet 2 when i gave in valid password the system willgive message please give valid password that particular messaage should be seen in QTP result,norepa and xl sheet

1728


how can i pass a "automation script" as a parameter in a function give me need full suggestion thank inadvance

1399