終於搞定了...
.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