Function return value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a form with a lot of command buttons on it. Most of the code in the
buttons perform the same error checking (with diffent fields) in the on click
code. I want to replace the code with a call to a function which will do the
checking and return a value based on the results. I would like to have the
on click event for each command button to start with this type of code:

If (CheckForErrors(fieldList........)) then goto exit_command_click

How do I get the function to return a value? I want the value to be a 1 if
error are found and a 0 if no errors. I know this must be simple, but I
can't figure it out.....

Thanks,
 
Hi,

I have a form with a lot of command buttons on it. Most of the code in the
buttons perform the same error checking (with diffent fields) in the on click
code. I want to replace the code with a call to a function which will do the
checking and return a value based on the results. I would like to have the
on click event for each command button to start with this type of code:

If (CheckForErrors(fieldList........)) then goto exit_command_click

How do I get the function to return a value? I want the value to be a 1 if
error are found and a 0 if no errors. I know this must be simple, but I
can't figure it out.....

Within the function's code you have to set the name of the function to a
value.

EX:

Function TodayIsSunday() As Boolean

If Format(Date, "dddd") = "Sunday" Then
TodayIsSunday = True
Else
TodayIsSunday = False
End If

End Function

(the else is rundant as False will be the default)
 
Back
Top