WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Miscellaneous

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

If Versus Switch


Question:

If the same thing can be accomplished with an "If" statement as a "Switch", is there a benefit by using "Switch"? Which is best?

Answer:

If you have many items to select from, the 'Switch' statement will run faster. If you set up an example and step through the statements, you'll see that with the 'If' statements, every line is processed. With the 'Switch' statement, it will only process the statements that fit the criteria.

If I have over 3 'If Then' statements, I try to use a Switch instead, to help keep the code cleaner.


Article ID:   W16025
File Created: 2004:03:30:15:42:18
Last Updated: 2004:03:30:15:42:18