0
我有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
你需要的是查找表。對於每個鍵(Color),您應該存儲一個電子郵件組值。至少,你應該使用switch語句。 http://msdn.microsoft.com/en-us/library/dft2z9yf(v=vs.80).aspx –
另請參閱http://msdn.microsoft.com/en-us/library/xfhwa508.aspx –
謝謝一堆! – user1152145