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

I have 5 save buttons in 5 tabs . The tabs are placed one after the other. My object repository have these added as 5 save buttons with name sav1, save 2, save 3 , save 4, save 5 .all are getting highlighted from OR but they are not getting clicked. After spying each button all the properties are same except First button Index 0 html id:=btnSaveTab1 outerhtml:=", Second button "html id:=btnSave "outerhtml:=", Third button "html id:=", outerhtml:=",

1506


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

1780


Hello, Is there any way to send the test results in html format (or any other) by email using outlook after the test run ends? thank you in advance

1925


What is accessibility check point?

799


How to handle the exceptions using recovery secnario manager in quicktest professional (qtp)?

781






How to call a test from another test?

871


How to automate a script in mainframes environment? I have the terminal emulator Add in. Describe in detail.

1863


• What type of testing questions will be asked for 2+ yrs exp people in interview?

1425


Explain the concept of object repository & how qtp recognizes objects?

717


Explain how you can replace string in qtp?

752


What are the general steps involved in the data driven framework?

704


Want to verify notepad reports using QTP framework or any other BV script method. Can anyone share the method to achieve it? Eg. Person Name is the header and the actual name is John then how can we verify weather person name is John

2312


To retrive the test data which tool vl use and whats basis u vl write test data? its urgent

1614


What is the new version of qtp which is recently released in the market?

786


How do you handle multiple banners(at the top the page, the banner is scrolling) in a web page(Dont take the name property(regular expression))

1830