0

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

蓝色波浪线位于“intCount”下方,仅供参考

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
4

1 回答 1

3

intSelection x intCount 应该是 intSelection *intCount 看看这个 MSDN 页面,它解释了可用于 VB.Net 的运算符

于 2012-05-03T00:01:36.903 回答