2020年5月8日 星期五

vb.net textbox只能輸入 數字,字母(大寫、小寫) [Textbox Restrict Char]


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
    Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtMount.KeyPress

        Select Case Asc(e.KeyChar)

       Case 8, 48 To 57, 65 To 90, 97 To 122

        '8 = SPACE

        '48 To 57 = 數字

        '65 To 90 = 字母(大寫)

        '97 To 122 = 字母(小寫)

                e.Handled = False

            Case Else

                e.Handled = True

        End Select

    End Sub

沒有留言:

張貼留言