ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Runtime (https://www.excelbanter.com/excel-programming/386811-runtime.html)

Brent

Runtime
 
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

JLGWhiz

Runtime
 
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.

"Brent" wrote:

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


JLGWhiz

Runtime
 
P.S. If you meant the difference in time and/or the
difference in amount. I don't know.

"Brent" wrote:

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


Jim Cone

Runtime
 

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"
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


All times are GMT +1. The time now is 10:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com