user1152145
user1152145

Reputation: 295

Looping through boolean variables

I have 8 boolean variables and i need to be able to add an email to an email string for each boolean that is true. I dont't know how to do it without writing a million if statements. Here is some of what i have:

   if bIsBlue then
      strEmailTo = strSalesEmail
      strEmailTo = strEmailTo & ", " & varBlueGrp
   End if
   if bIsRed then
      strEmailTo = strSalesEmail
      strEmailTo = strEmailTo & ", " & varRedGrp
   End if
   if bIsGreen then
      strEmailTo = strSalesEmail
      strEmailTo = strEmailTo & ", " & varGreenGrp
   End if
   if bIsBrown then
      strEmailTo = strSalesEmail
      strEmailTo = strEmailTo & ", " & varBrownGrp                            
   End if
   if bIsBlue and bIsRed then
      strEmailTo = strSalesEmail
      strEmailTo = strEmailTo & ", " & varBlueGrp & ", " & varRedGrp
   End if
   if bIsBlue and bIsGreen then
      strEmailTo = strSalesEmail
      strEmailTo = strEmailTo & ", " & varBlueGrp & ", " & varGreenGrp
   End if

Upvotes: 0

Views: 260

Answers (1)

Bhavin Vora
Bhavin Vora

Reputation: 451

I suggest u make the array of those boolean variables and then iterate threw that so u can make a faster access to the all variables.

Upvotes: 1

Related Questions