hai..friends ....what is the difference between function and
sub procedure ....here every one know's theoretically here
my question is what is the meaning of function can return
the value and sub can't return the value...can you give one
example with some values for that ....what does it mean ?
how function can return the value...sub can not...any one
please...........with example



hai..friends ....what is the difference between function and sub procedure ....here every one know&..

Answer / monika

function myfunction(a,b)
myfunction=a+b
End function

returnvalue=myfunction(5,9)
msgbox returnvalue

it will display value returned by function and stored in returnvalue variable as 14

sub myfunction(a,b)
myfunction=a+b
End sub

returnvalue=myfunction(5,9)
msgbox returnvalue

it will throw error as no value returned by sub

sub myfunction(a,b)
c=a+b
msgbox c
End sub

call myfunction(5,9)

it will display 14 inside sub

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More VB Script Interview Questions

write a vb script to display first 5 odd numbers from 1 to 100

4 Answers  


can anyone send me a vb scripts code for clicking on a link and coming back on home page again does the same for many links on a web page.

0 Answers   Synechron,


How will you release the memory acquired by an array variable in vbscript?

0 Answers  


Inorder to avoid Message box while writing script which alternative method can be used?

1 Answers  


best training centre in bangalore

2 Answers  






Explain different types of segment?

0 Answers  


what is the purpose of the Reporter.ReportEvent in QTP and also please give the brief description about Reporter.ReportEvent ?

4 Answers   CybAge,


Hello Friends , I am the new joinner of this website. I am working with Sapient ,Gurgoan I would like to ask few qurries regarding the QTP Tool of (Testing) Currently working on QTP Tool . I would like to no learn VB Script can u name some Books which i get in market. And a small issue in QTP I had 2 users right i have to login and send the document from this user to second user right. when i am send this doc some contendId number generates right. now i am loging into second user and i have to search for that contentId right i found it now i dont want to accept the document so i had an opption of check out ok i have to click on check out my QTP Code is like this Browser(" ").Page(" ").WebTable(" ").ChildItem (3,5,"Image",0).click Browser(" ").Page(" ").Link("ChecK Out").Click i new this code is perfectly right but when i am run the script i have to click on that particular contentId and click on check out but now the Problem is started the error is the document has been already checked out remeber every time my content id changes means it is the new contentId which is not been used atleast once Please help me out in this issue i am in big trouble

0 Answers   GCE, Sapient,


What are the different types of operators and their order of precedence?

0 Answers  


How to create MSAcess table foriegn key

1 Answers  


What is the scope of a constant declared using public?

0 Answers  


how do you make the variable declaration mandatory?what is the use of "option explicit"?

2 Answers  


Categories