VB中的If语句出现问题

时间:2020-03-19 21:21:38

标签: vb.net if-statement

我是VB的新手,所以我很抱歉,如果答案很明显,但我正在尝试执行if else语句。

我背后的逻辑是

如果myId = 10、11或12,则执行a,否则,执行b

我没有得到预期的结果,这使我相信if else语句中的语法不正确。

这是代码:

If ProfileLists.myId = 10 Or ProfileLists.myId = 11 Or ProfileLists.myId = 12 Then
    For Each item As Dictionary(Of String, Object) In data("Column1")
        If (Not CheckReturnedListForSectors(item.ElementAt(2).Value, item.ElementAt(0).Value)) Then
            reports.Rows.Add(item.ElementAt(4).Value, RoundGrowthValue(item.ElementAt(5).Value), TrimExecSummary(item.ElementAt(6).Value), ConvertReportUrl(item.ElementAt(9).Value))
        End If
    Next
    For Each item As Dictionary(Of String, Object) In data("Column1")
        If (Not CheckReturnedListForSectors(item.ElementAt(2).Value, item.ElementAt(0).Value)) Then
            reports.Rows.Add(item.ElementAt(4).Value, RoundGrowthValue(item.ElementAt(7).Value), TrimExecSummary(item.ElementAt(5).Value), ConvertReportUrl(item.ElementAt(7).Value))
        End If
    Next
End If

1 个答案:

答案 0 :(得分:1)

您的代码不包含B代码。有效的VB如果如下所示:

If something Then
     a()
Else
     b()
End If
相关问题