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'(兩個條件語句代替兩個條件中的一個語句)並且工作正常。