VBA "Any" logical operator -


is there vba operator checks if of arguments evaluates true? dislike syntax of having write and or or many times multiple arguments, buttons have "select all/deselect all" type of functionality.

ex.

if checkbox1 = true or checkbox2 = true or ... checkbox10 = true 

could written more succinctly as

if any(checkbox1, checkbox2 , ..., checkbox10) 

?

also, there performance considerations writing such long if statement? noticed after adding macro or vba code, access form loads more slowly, don't know if has this.

edit

i tried testing suggested code below

public sub text_x() dim a, b, c, d, e, f, g, h, i, result boolean dim t1, t2 single  = false b = false c = false d = false e = false f = false g = false h = false = true  t2 = timer = 1 10000000     result = false     if or b or c or d or e or f or g or h or             result = true     else             result = false     end if next t2 = timer - t2   t1 = timer = 1 10000000     result = false     select case true         case a, b, c, d, e, f, g, h,             result = true         case else             result = false     end select next t1 = timer - t1   msgbox ("timer1 " & t1 & vbcrlf & "timer2 " & t2) end sub 

however, timing depends on 1 put first in code (t1 or t2). why this?

you can approximate case switch, like:

select case true     case checkbox1, checkbox2, checkbox3, ... checkbox10 '# sure enumerate of checkboxes here          msgbox "any"     case else         msgbox "not" end select 

it's bit easier read/maintain huge if statement, there not equivalent any function in vba, natively.

(you can use test it)

sub x() dim a, b, c  = false b = true c = false   select case true     case a, b, c         msgbox "any"     case else         msgbox "not" end select  end sub 

Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -