Hmmmm.
Lets see, I type in [vbcode], hit "Enter", paste my code from my project, hit "Enter", then type [/vbcode], hit "Enter", click waving smilie, hit the submit button, and...
VB Code:
Private Sub Command1_Click()
'This is a simple illustration of returning values from a function.
'Lets say you wanted a function to return the sum of 5 numbers.
'Lets say you had those 5 numbers in an array:
Dim AN_ARRAY(4) As Long
'And lets say you wanted the sum placed in the following variable:
Dim THE_SUM As Long
'lets say that array had the values 1,2,3,4,9"
AN_ARRAY(0) = 1
AN_ARRAY(1) = 2
AN_ARRAY(2) = 3
AN_ARRAY(3) = 4
AN_ARRAY(4) = 9
'so, this will now access the function:
THE_SUM = MY_FUNCTION(AN_ARRAY)
MsgBox THE_SUM
End Sub
Private Function MY_FUNCTION(ByRef inArr() As Long) As Long
'This function will return a 1 dimensional value
'representing the sum of all the numbers in inArr()
Dim MyI As Long
MY_FUNCTION = 0
For MyI = 0 To UBound(inArr)
MY_FUNCTION = MY_FUNCTION + inArr(MyI)
Next MyI
End Function