Log in

View Full Version : [SLEEPER:] Declaring Constants conditionally. Run something only once in a loop



sunnyimran
09-07-2019, 12:06 AM
Hi all,
I am doing some scripting in VBA for Visio-2016. At a point I came across two situations:
Q-1 How to decalare/initialize a constant that is based on some condition to met?
e.g IF Type=M Define Constant with values as below:

Const X1=1, Y1=1, X2=5, Y2=5
IF Type=S Define Constant with values as below:
Const X1=10, Y1=10, X2=50, Y2=50
Furthermore, is it possible to create a UDT (User Defined Datatype) of constants like above initialize with different values based on some condition to be met?
How?
Q-2 When iterating a loop for known No. of times like 16 times. I want a couple of vba statements to run only at counter value=1. Means only at loop's first pass. Those statements must be neglected on subsequent passes. Anything more better than using an IF loop=1? because in that case IF will be checked on every iteration. while I need it only once at first pass in the loop.
How?
Waiting.

sunnyimran
09-16-2019, 05:29 AM
Hi all,
I am doing some scripting in VBA for Visio-2016. At a point I came across two situations:
Q-1 How to decalare/initialize a constant that is based on some condition to met?
e.g IF Type=M Define Constant with values as below:

Const X1=1, Y1=1, X2=5, Y2=5
IF Type=S Define Constant with values as below:
Const X1=10, Y1=10, X2=50, Y2=50
Furthermore, is it possible to create a UDT (User Defined Datatype) of constants like above initialize with different values based on some condition to be met?
How?
Q-2 When iterating a loop for known No. of times like 16 times. I want a couple of vba statements to run only at counter value=1. Means only at loop's first pass. Those statements must be neglected on subsequent passes. Anything more better than using an IF loop=1? because in that case IF will be checked on every iteration. while I need it only once at first pass in the loop.
How?
Waiting.

No one interested to answer? No ideas ?