Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stopping a function

Status
Not open for further replies.

mpnorris

IS-IT--Management
Dec 31, 2002
66
US
Here is my situation. I have a series of IF statements. I want to be able to put in code to stop the program from continuing if one of these conditions are met. IF none of the conditions are met the ELSE statement should run.

I have the code working except for the Else statement also runs. I was hoping to put in code at the end of each IF statments to stop the code from continuing.

I think this should be easy but I do not know the syntax. Any help would be greatly appreciated.
 
Change your Else statement to another ElseIf statement and make your Else statement exit the function.

John Green
 
This is the format that you should follow. You can have unliminted ElseIf's with their corresponding statements prior to the final Else.

If <expression> Then
'[statements]
ElseIf <expression> Then
'[statements]
ElseIf <expression> Then
'[statements]
ElseIf <expression> Then
'[statements]
ElseIf <expression> Then
'[statements] ...
Else
'[statements]
End If

If you follow this format you will get all of your conditions to work including the final else which corresponds to the the false answers of all the above listing IF's.

Bob Scriver

Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???

 
hankyou. Your responses were very helpful. Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top