【发布时间】:2016-07-09 04:22:56
【问题描述】:
使用时
If Then
'Do Something
Else If
'Do Something
End If
如果第一个和第二个条件为真,是只执行第一个还是同时执行两个?
出于某种原因,当我有此代码时:
Dim Report As String
If (DateRange_Pro_TotalCount > 0) Then
Dim DateRange_Pro_ReportStr As String
DateRange_Pro_ReportStr = "Total Referrals: " & DateRange_Pro_TotalCount & vbNewLine _
Report = Report & DateRange_Pro_ReportStr
ElseIf (DateRange_InPro_TotalCount > 0) Then
Dim DateRange_InPro_ReportStr As String
DateRange_InPro_ReportStr = "Total Referrals: " & DateRange_InPro_TotalCount & vbNewLine _
Report = Report & DateRange_InPro_ReportStr
End If
'next statement prints report variable to textBox
该语句只执行第一个条件,即使两个条件都为真。我将“Else If”更改为“End If”和“If”(两个不同的条件语句,而不是一个具有两个条件的语句)并且它起作用了。
【问题讨论】:
标签: vba if-statement ms-access-2010