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:
  1. Private Sub Command1_Click()
  2.     'This is a simple illustration of returning values from a function.
  3.     'Lets say you wanted a function to return the sum of 5 numbers.
  4.     'Lets say you had those 5 numbers in an array:
  5.     Dim AN_ARRAY(4) As Long
  6.     'And lets say you wanted the sum placed in the following variable:
  7.     Dim THE_SUM As Long
  8.     'lets say that array had the values 1,2,3,4,9"
  9.     AN_ARRAY(0) = 1
  10.     AN_ARRAY(1) = 2
  11.     AN_ARRAY(2) = 3
  12.     AN_ARRAY(3) = 4
  13.     AN_ARRAY(4) = 9
  14.     'so, this will now access the function:
  15.    
  16.     THE_SUM = MY_FUNCTION(AN_ARRAY)
  17.     MsgBox THE_SUM
  18. End Sub
  19. Private Function MY_FUNCTION(ByRef inArr() As Long) As Long
  20.     'This function will return a 1 dimensional value
  21.     'representing the sum of all the numbers in inArr()
  22.     Dim MyI As Long
  23.     MY_FUNCTION = 0
  24.     For MyI = 0 To UBound(inArr)
  25.         MY_FUNCTION = MY_FUNCTION + inArr(MyI)
  26.     Next MyI
  27. End Function