Consulting

Results 1 to 2 of 2

Thread: Declaring Constants conditionally. Run something only once in a loop

  1. #1

    Declaring Constants conditionally. Run something only once in a loop

    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.

  2. #2
    Quote Originally Posted by sunnyimran View Post
    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 ?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •