How can we return a value from User Defined Function ?
For Eg. we have 2 functions. In Fun1 i am getting 2 values
(a,b) and i am addding those 2 and storing in to another var
(c). Now i want to pass that var(c) to another function
(fun2). What will be the script?

Answers were Sorted based on User's Feedback



How can we return a value from User Defined Function ? For Eg. we have 2 functions. In Fun1 i am ge..

Answer / chivukula.kumar

'Try this Code in Only MS-Excel

'After opened should be press Alt+F11
'select and double click the ThisWoorkbook in VBA Project
leftside of application
' paste this code in that

Private Sub Workbook_Open()
Call add(1000, 20000, c)
Call subb(c, 20000)
End Sub

'Creation of Fun1 and Fun2(add and subb)

Function add(a, b, c)
a = a + b
c = a
MsgBox c
End Function

Function subb(c, d)
sb = c - d
MsgBox sb
End Function

Is This Answer Correct ?    10 Yes 3 No

How can we return a value from User Defined Function ? For Eg. we have 2 functions. In Fun1 i am ge..

Answer / sangee

Call add(40,20,c)
Call subs(c,10)
Function add(a,b,c)
c=a+b
msgbox c
End Function

Function subs(c,d)
e=c*d
msgbox e
End Function

Is This Answer Correct ?    6 Yes 2 No

How can we return a value from User Defined Function ? For Eg. we have 2 functions. In Fun1 i am ge..

Answer / siri

'vbscript
dim a:a=20
dim b:b=30
dim d
d=add(a,b)
call subtract(d)

function add(a,b)
dim c
c=a+b
add=c
end function
function subtract(d)
dim f:f=10
dim e
e=d-f
msgbox e
end function

Is This Answer Correct ?    6 Yes 3 No

How can we return a value from User Defined Function ? For Eg. we have 2 functions. In Fun1 i am ge..

Answer / siri

'vbscript
'create two functions
dim a,b,d
a=20,b=30
dim c
d=add(a,b)
msgbox d
call subtract(d)

function add(a,b)
dim c
c=a+b
add=c 'add is the function name:this statetment can
return c value
end function

function subtract(c)
dim f,e
f=20
e=d-c
msgbox e
End function

Is This Answer Correct ?    6 Yes 5 No

How can we return a value from User Defined Function ? For Eg. we have 2 functions. In Fun1 i am ge..

Answer / varun

dim a,b,c
fun1 a,b,c
fun2 c
msgbox("done")

sub fun1(a,b,c)
a = cint(inputbox("first number"))
b = cint(inputbox("second number"))
c = a + b
End sub

sub fun2(c)
msgbox(c)
end sub

Is This Answer Correct ?    2 Yes 1 No

How can we return a value from User Defined Function ? For Eg. we have 2 functions. In Fun1 i am ge..

Answer / saahasikan

Please tell me how to write and call functions in classic ASP

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More VB Script Interview Questions

How to Import data from a file (file is on the desktop) to the data table

2 Answers   IBM,


w r p syed then output was deys and click eysd and click ysde and click sdey and click deys and click eysd............

2 Answers   Cap Gemini, iGate,


write a vb script to display the code "vbscripting" alphabet by alphabet(i e 1st v then b and up to g)

2 Answers  


Hi I don't have any idea on VBscript. can any one point me to a good web site to learn VBscript. Regards lina

2 Answers  


Hello friends..... Can any give the methods for Ms-Access, and Mozilla firefox in Automation Object Model in QTP. Please give me currect answers... if you do not understand my question please don't give answers. Thanking you.

0 Answers  






Develop a parameterized action that accomplishes the following a. Launch a browser of users choice ( example : IE, chrome etc) b. Open up a search engine (Google, Bing etc) c. Perform a search d. Click a particular link depending on the user’s choice ( 1st , 2nd or third link)

0 Answers   TCS, Wipro,


How to open excel in vb script?

0 Answers  


which is the bset training centre to learn automation tools?

2 Answers  


Which is the default Data types in VBScript?

7 Answers   AppLabs,


hey please tell me how to retriev data from excel sheet which puts the login name and password in the application? plz send me the code..please help me

6 Answers   HP,


I am running a windows based application.While running the script on QTP ,The Application pop-up an Error Message as "object Disabled" in two different scenarios Scenario 1-->The Application pop-up up a Message for Max Session Reached(as the application is set to hold 2 session and if if crosses the pre-defined limit then the error message pop-up) Scenario 2-->When Network connectivity is disabled the Application screen gets greyed out in colour with no operation possible. Now through Exception handling features in QTP ,we need to do the following For Scenarion 1-->Through Exception handling we need to just accept the Message pop-up in the Application and and resume with the call function as is for Scenario 2--> Through Exception Handling featutes on QTP we need to shut down the client , restart the client and resume the call functions as it is Note: The Application returns an Error Message as "object disabled" in both the cases i.e for pop-up message and when the Apllication getting greyed out due to Network failure how can we enhance the script in such a way that for the same error message retured by the application in two different and how to handle them????

2 Answers   Sasken,


1. How to handle object implementation change in DP for Ex: i have login page with username,pasword (editboxes),login,cancel(buttons). Here i written DP code for login page with the help properties. My questions: 1.If properites are changing dynamically i will do (i want code for that) 2.if objects are changed dynamcally i will do (i wnat code for that)

0 Answers   iFlex,


Categories