我在Windows上运行的程序形成的Visual Basic和IM试图使多个计数器在VB.NET使用条件语句来算
这里是我的代码:
If txtAnswer.Text = nMathSum Then
nCount = nCount + 1
lblCorrect.Text = nCount
ElseIf txtAnswer.Text <> nMathSum Then
nIount = nIount + 1
lblIncorrect.Text = nIount
End If
If txtAnswer.Text = nMathDiff Then
nCount = nCount + 1
lblCorrect.Text = nCount
ElseIf txtAnswer.Text <> nMathDiff Then
nIcount = nIcount + 1
lblIncorrect.Text = nIout
End If
它想看看有多少次我回答正确和不正确
柜台的总和工作正常,但差异的计数器有问题。 当我输入正确的答案时,它会转到错误的标签。
nIount和ncount?当您选择怪异标识符名称时会发生这种情况。帮助您编写无bug代码的不重要的代码是GoodAnswerCount和BadAnswerCount。 – 2012-04-06 16:46:55
这就是它:nIount,ncount或nIout? Hans Passant是正确的:使用更好的标识符名称! – mjv 2012-04-06 16:48:46