我已经在网上寻找答案,但自己无法复制该错误,并且不知何故,文本框似乎是透明的,无法点击;但是,如果您将“Text =”属性设置为其中包含一条消息,则文本框似乎可以正常工作。
我已经多次查看属性和代码,似乎没有任何问题。没有要求文本框是透明的,而且我没有看到任何东西会阻止它接受用户输入。
......“破碎”的代码是:
Public Class GuessingGame
Const MIN As Integer = 1
Const MAX As Integer = 50
Private Sub btnCheckGuess_Click(sender As System.Object, e As System.EventArgs) Handles btnCheckGuess.Click
Randomize()
Static secretNumber As Integer = Int((MAX - MIN + 1) * Rnd() + MIN)
Static Count = 0
Dim guess As Integer
Count = Count + 1
guess = Val(Me.txtPlayerGuess.Text)
If guess < MIN Or guess > MAX Then 'invalid guess
MessageBox.Show("Guess out of range")
ElseIf guess = secretNumber Then
Me.lblMessage.Text = "You guessed it!" 'correct
MessageBox.Show(Count)
Else
Call GiveHint(secretNumber, guess)
End If
End Sub
Private Sub txtPlayerGuess_TextChanged(sender As System.Object, e As System.EventArgs)
'Clear the current answer when the user begins to type a new value
Me.lblMessage.Text = Nothing
End Sub
Private Sub GiveHint(firstNum As Integer, ByVal secondNum As Integer)
If firstNum > secondNum Then
MessageBox.Show("Too low.")
Else
MessageBox.Show("Too high.")
End If
End Sub
End Class
任何人对导致此问题的原因以及如何解决此问题有任何想法?