If (txtUsername.Text >= Chr(48) And txtUsername.Text <= Chr(122)) Then
'ภาษาอังกฤษ
ElseIf (txtUsername.Text >= Chr(161) And txtUsername.Text <= Chr(206)) Then
'ภาษาไทย
End If
Select Case Asc(e.KeyChar)
Case 48 To 122
e.Handled = False
Case 8, 13, 46 ' Backspace = 8, Enter = 13, Delete = 46
e.Handled = False
Case Else
e.Handled = True
MessageBox.Show("กรุณาระบุข้อมูลเป็นภาษาอังกฤษ")
End Select
Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress
Select Case Asc(e.KeyChar)
Case 48 To 57
e.Handled = False
Case 8, 13, 46 ' Backspace = 8, Enter = 13, Delete = 46
e.Handled = False
Case 161 To 240
e.Handled = False
Case Else
e.Handled = True
MessageBox.Show("กรุณาระบุข้อมูลเป็นภาษาไทย")
End Select
End Sub