终于搞定了...
.Net的写法跟VB6差太多了
复制程式
Public Class Form1
Dim r As New Random
Dim i As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
i = r.Next(65, 90)
Label1.Text = Chr(i)
End Sub
Private Sub TextBox1_KeyPress1(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If e.KeyChar = i Then 'e.KeyChar 跟VB6里的KeyAscii意思一样
TextBox1.Text = ""
e.Handled = True '对应VB6的 KeyAscii=0 ,意思不一样...但是作用都是不让TEXTBOX收到输入
i = r.Next(65, 90)
Label1.Text = Chr(i)
End If
End Sub
End Class