Runtime

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

Guest

Does anyone know the difference in runtime and memory usage for
IF..Then..Else and a Switch statement in VBA, when the two are equivalent
expressions? Thank you.

Brent
 
This is a synopsis, but not necessarily complete.

Runtime is while the code is executing.

Memory usage is the storage required to compile
and execute a procedure.
'
If..Then..Else sets a condition which if met, or
not met will result in some response, or lack of
response as determined by the user, with the
Else occuring when the first condition does not
apply.'

The Switch function provides a facility to use
different definitions for the same variable and
match the definitions modifier for each switch.'

I don't know that you could say any two are
equivalent, but you could conceivably get a similar
result using Switch in place of an If...Then.

For more information, refer to the VBA help files.
 
P.S. If you meant the difference in time and/or the
difference in amount. I don't know.
 
All of the expressions in a Switch or IIF statement are evaluated whether or not
they are true. An If/Then or Select case statement stops evaluation with the
first condition that is True. Draw your own conclusion.

I tend to favor the Select Case statement for more than 3 conditions.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Brent" <[email protected]>
wrote in message
Does anyone know the difference in runtime and memory usage for
IF..Then..Else and a Switch statement in VBA, when the two are equivalent
expressions? Thank you.

Brent
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

vba in excel 2007 5
dll files in Excel VBA or ADO 5
Runtime error '16': 2
Excel 2007 Charts & Memory Leak?? 7
SQL vs. VBA 2
Range Syntax 19
Windows 7 Problem with Services 4
Changing object properties permanently at runtime 4

Back
Top