在while语句中VB 2010中的“语句结束预期”错误

时间:2012-05-02 23:56:45

标签: vb.net visual-studio-2010

我有一行代码在一个语句中工作但不是第二个语句。我不确定我做错了什么,所以任何帮助都会受到赞赏。我正在缓慢但肯定地学习,并且由于我在这里找到的帮助,这是一个不小的差距=)错误发生在SECOND intResult = intSelection x intCount Do循环的While

蓝色波浪线在“intCount”下只是FYI

Dim intSelection As Integer
Dim intCount As Integer = 0
Dim intResult As Integer
Dim strDisplay As String


Private Sub txtSelection_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSelection.TextChanged

End Sub

Private Sub btnSelection_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelection.Click
    If intSelection >= 0 And intSelection <= 12 Then
        Do While AdditionToolStripMenuItem.Checked = True And intCount <= 12
            intResult = intSelection + intCount
            strDisplay = intSelection & " + " & intCount & " = " & intResult
            lstResults.Items.Add(strDisplay)
            intCount += 1
        Loop

        Do While MultiplicationToolStripMenuItem.Checked = True And intCount <= 12
            intResult = intSelection x intCount
            strDisplay = intSelection & " x " & intCount & " = " & intResult
            lstResults.Items.Add(strDisplay)
            intCount += 1
        Loop


    Else
        MsgBox("Please enter a value between 0 and 12", , "Input Error")


    End If
End Sub

1 个答案:

答案 0 :(得分:3)

intSelection x intCount应该是intSelection * intCount看看this MSDN page它解释了可用于VB.Net的运算符