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 is a Step generator used in UFT?

870


Is there any relation between Keyword Driven Framework and Recording modes provided in QTP( whether Recording modes are applied on keyword driven framework or not?)

1636


1--How many functions u develop 2--What is an array 3-- where is ur server 4--U involved in unit testing 5--how ur test the background colour using QTP

1743


How to integrate the qualitycenter with qtp

1966


How you know that a test case is a regression test case

3447


What is the difference between byref and byval in qtp?

782


How to use parameterization in qtp?

824


Differences between quicktest professional (qtp) and winrunner?

872


If object is not recognized by qtp but the object is standard object what is your approach?

781


If a button named "CLICK" is recorded in low level recording mode , what will be the values stored for "name" property of that button in object repository ?

1944


Hi frens! I am testing VB project with MS Access database. At add button click my record is storing in data table and it is shown in datagrid. So at Delete button click i want to check datagrid rows 9before and after delete). so how can i do it using descriptive programming?

1713


How do you delete unwanted results in qtp?

810


What is object repository in qtp?

748


I am a new tester that needs to create an automatic script involving security questions. On a webpage I need to select a security question(which are random) from a drop down menu, and then input the answer as the last word from the security question. I have the script set-up to automatically select the first security question from the drop down. The problem I am having is trying to insert the security answer. How do I insert the security answer based on the selection from the security question?

2053


banking project description for software tester

7210