Results 1 to 4 of 4

Thread: checking multiple variables (resolved)

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    125

    Resolved checking multiple variables (resolved)

    fairly simple question, is there any way to check the status of multi variables at once? I figure if it is possible they would have to be variables with arrays

    such as,

    currently that i have to use:
    VB Code:
    1. dim var(1 to 5) as boolean
    2. If var(1) = true then 'do whatever code goes here
    3. If var(2) = true then 'do whatever code goes here
    4. If var(3) = true then 'do whatever code goes here
    5. If var(4) = true then 'do whatever code goes here
    6. If var(5) = true then 'do whatever code goes here

    what i have want, but didnt work out:
    VB Code:
    1. dim var(1 to 5) as boolean
    2. If var(1 to 5) = true then 'do whatever code goes here
    Last edited by Resilience; Aug 19th, 2005 at 03:17 AM. Reason: resolved
    --- Science does not explain why things are what they are. What we get from Science is our interpretation of how things do what they do.
    --- No Scientific law of the universe is stable, we did not create it, and we will never understand all of its abilities.
    --- What we determine as reality is a mere assumption of what tomorrow will be based on what yesterday was.

  2. #2
    Frenzied Member Devion's Avatar
    Join Date
    Sep 2000
    Location
    The Netherlands
    Posts
    1,049

    Re: checking multiple variables

    Here ya go

    VB Code:
    1. dim intCount as integer, ysnOk as boolean
    2.  
    3. ysnOk = true
    4.  
    5. for intCount = 1 to ubound(Var)
    6.    if var(intcount) = false then
    7.        ysnOk = false
    8.        exit for
    9.    end if
    10. next
    11.  
    12. if ysnOk then
    13.    ' Do your code if all checks out :)
    14. end if

    Or the slightly different version...

    VB Code:
    1. dim intCount as integer, ysnOk as boolean
    2.  
    3. for intCount = lbound(var) to ubound(Var)
    4.    if not var(intcount) then
    5.         ysnOk = not ysnOk
    6.         exit for
    7.    end if
    8. next
    9.  
    10. if ysnOk then
    11.    ' Do your code if all checks out :)
    12. end if
    Last edited by Devion; Aug 19th, 2005 at 03:00 AM.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    125

    Re: checking multiple variables

    thanks
    --- Science does not explain why things are what they are. What we get from Science is our interpretation of how things do what they do.
    --- No Scientific law of the universe is stable, we did not create it, and we will never understand all of its abilities.
    --- What we determine as reality is a mere assumption of what tomorrow will be based on what yesterday was.

  4. #4
    Frenzied Member Devion's Avatar
    Join Date
    Sep 2000
    Location
    The Netherlands
    Posts
    1,049

    Re: checking multiple variables (resolved)

    Your welcome :-)

Posting Permissions

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



Click Here to Expand Forum to Full Width