循环布尔变量
我有 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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议你制作这些布尔变量的数组,然后迭代抛出它,这样
你可以更快地访问所有变量。
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.