Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access to Functios return value

Status
Not open for further replies.

ajtsystems

IS-IT--Management
Jan 15, 2009
80
GB
My script is fairly simple but I cant seem to get the functions return value out


Dim retValue

' Call the function with and without the Call keyword.
Call ShowSum(3, 4)
ShowSum 5, 6

retValue = ShowSum(7, 8)
MsgBox "The function returned: " & retValue

Function ShowSum(value1, value2)
Dim sum

' Determine and display the sum.
sum = value1 + value2
MsgBox "The sum is: " & sum

' Set the function's return value.
ShowSum = sum
End Function

wscript.echo sum
 
the last line '
wscript.echo sum
is never going to echo anything, the variable sum is rightly declared in the Function ShowSum and therefore is not available outside of the scope of that Function

this shoudl be giving you something though
retValue = ShowSum(7, 8)
MsgBox "The function returned: " & retValue
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top