Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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


.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default 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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Function returning unexpected value Paul Excel Worksheet Functions 7 July 22nd 09 08:29 PM
INDIRECT function returning REF# Don Kline Excel Worksheet Functions 2 March 23rd 09 03:13 PM
IF Function Returning Range Brian Excel Discussion (Misc queries) 0 September 16th 08 03:19 PM
IF Function returning range Brian Excel Discussion (Misc queries) 5 September 16th 08 02:26 AM
MAX Function not returning correct value Phil Excel Worksheet Functions 4 April 28th 06 10:14 PM


All times are GMT +1. The time now is 05:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"