循环遍历布尔变量

时间:2012-01-16 15:40:22

标签: vb.net loops boolean

我有8个布尔变量,我需要能够为每个布尔值的电子邮件字符串添加一封电子邮件。如果不写一百万条if语句,我就不知道怎么做。以下是我的一些内容:

   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

1 个答案:

答案 0 :(得分:1)

我建议你制作那些布尔变量的数组,然后迭代扔掉它 你可以更快地访问所有变量。