View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone[_2_] Jim Cone[_2_] is offline
external usenet poster
 
Posts: 1,549
Default Function to return two values

Maybe...
'--
Function IcelandBanking(ByRef strMsg As String) As Boolean
Dim WontPay As Long
Dim NoReserves As Boolean

'Code here to calculate WontPay and NoReserves
WontPay = 0
NoReserves = True

If WontPay 0 Then
strMsg = "Small Withdrawals Only"
Else
strMsg = "You are out of luck"
End If
IcelandBanking = NoReserves
End Function
'--
Sub FinancialStatus()
Dim strText As String
MsgBox IcelandBanking(strText) & vbCr & strText
End Sub
--
Jim Cone
Portland, Oregon USA



"Jac Tremblay"

wrote in message
Hi,
Is it possible to create a function that will return two values, a boolean
and a string?
I need to exit the main procedure if the data checked by the function is not
valid and also display a message according to the particular validation.
For example:
If Not DataIsValid Then
Msgbox strErrorMsg ' Returned from the function
Exit Sub
end IF
Thanks
--
Jac Tremblay