Explicit Function return (RESOLVED)
Hello everybody
I have this very simple question. Suppose the following function :
Code:
Function ABC As Boolean
Do While <condition>
If <condition> Then
<statements>
On Error GoTo ErrorHandler
<other_statements>
ABC = True ' Correct master password
Return ' Return
End If
GoTo ShuntErrorHandler
ErrorHandler:
MsgBox "ERROR!ï", vbCritical
If Err.Number Then
Resume ShuntErrorHandler
End If
ShuntBadErrorHandler:
Loop
End Function
In this code, I just want the function to return a value and give control back to the calling procedure-function. But this does not occur! How do I tell the function to exit. Does the assignment of the function value need to be the last statement of the function?
thx, in advance
George Papadopoulos
Re: Explicit Function return
That should do it.
Phreak
Re: Explicit Function return
Something like this:
Function ABC As Boolean
Do While <condition>
ABC = False
On Error GoTo ErrorHandler
If <condition> Then
<statements>
<other_statements>
ABC = True ' Correct master password
Exit Function ' Return
End If
Loop
exit function
ErrorHandler:
MsgBox "ERROR!ï", vbCritical
If Err.Number Then
Resume ShuntErrorHandler
End If
End Function
the forums acting up
VB Code:
Function ABC As Boolean
Do While <condition>
ABC = False
On Error GoTo ErrorHandler
If <condition> Then
<statements>
<other_statements>
ABC = True ' Correct master password
Exit Function ' Return
End If
Loop
exit function
ErrorHandler:
MsgBox "ERROR!ï", vbCritical
If Err.Number Then
Resume ShuntErrorHandler
End If
End Function
Re: Explicit Function return
ok. that was it. I just wasn`t aware of the statement. I was more on the grounds of the Return statement in C.
thx, for the help!