を使用する場合
If Then
'Do Something
Else If
'Do Something
End If
1 番目と 2 番目の条件が true の場合、最初の条件だけを実行しますか、それとも両方を実行しますか?
何らかの理由で、このコードがある場合:
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' (2 つの条件を持つ 1 つのステートメントではなく 2 つの diff. 条件付きステートメント) に変更したところ、機能しました。