I know how to get a value back from a function.
Function Hi() as String
Hi = "Hello"
End Function
How do you get two values back with out running the function again?
Function Hi() as String
Hi = "Hello"
Hi = "GoodBye"
End Function
Printable View
I know how to get a value back from a function.
Function Hi() as String
Hi = "Hello"
End Function
How do you get two values back with out running the function again?
Function Hi() as String
Hi = "Hello"
Hi = "GoodBye"
End Function
Use an Array:
Code:Function Hi()
Hi(0)="Hello"
Hi(1)="Goodbye"
End Function
Private Sub Form_Load()
Debug.Print Hi(0)
Debug.Print Hi(1)
End Sub
You can return them in 1 string and use the Split() function to distinguish them.
Code:Function Hi() As Variant
Hi = Split("Hi,GoodBye", ",")
End Function
Private Sub Command1_Click()
Ret1 = Hi(LBound(Hi)) 'Get 1st value
Ret2 = Hi(UBound(Hi)) 'Get 2nd value
Print "Value 1: " & Ret1
Print "Value 2: " & Ret2
End Sub
Both works great!