![]() |
Returning value from function
I don't understand how to return a value from a function. If I wanted to
return the value for X in testee to test, how can I fix this code? Sub test() Dim X As Integer X = 1 testee (X) MsgBox X End Sub Function testee(X) X = 1 + 1 End Function |
Returning value from function
The function itself becomes the return value.
Sub test() dim x as integer x = 1 x = testee(x) msgbox x End Sub Function testee(x as integer) as integer testee = x + 1 End function -Brad -----Original Message----- I don't understand how to return a value from a function. If I wanted to return the value for X in testee to test, how can I fix this code? Sub test() Dim X As Integer X = 1 testee (X) MsgBox X End Sub Function testee(X) X = 1 + 1 End Function . |
Returning value from function
Option Explicit
Function testee(X) as integer X = 1 + 1 testee = X End Function -- Robin Hammond www.enhanceddatasystems.com Check out our XspandXL add-in "Sally" wrote in message ... I don't understand how to return a value from a function. If I wanted to return the value for X in testee to test, how can I fix this code? Sub test() Dim X As Integer X = 1 testee (X) MsgBox X End Sub Function testee(X) X = 1 + 1 End Function |
Returning value from function
Hi Sally,
I've listed another example below. Hope it helps. Regards, James S Sub Test() Dim x As Integer x = 1 MsgBox "New value = " & GetNewValue(x) End Sub Function GetNewValue(x As Integer) as Integer GetNewValue = x + 1 End Function -----Original Message----- I don't understand how to return a value from a function. If I wanted to return the value for X in testee to test, how can I fix this code? Sub test() Dim X As Integer X = 1 testee (X) MsgBox X End Sub Function testee(X) X = 1 + 1 End Function |
All times are GMT +1. The time now is 05:13 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com