Source code berikut ini digunakan untuk membatasi penulisan pada textbok hanya menerima input huruf.
Buat suatu project dengan :
1 Form
1 TextBox
Copy source code berikut pada Form :
Public Sub InputHuruf(ByVal KeyAscii As Integer)
If Not (KeyAscii >= Asc("a") & Chr(13) And KeyAscii <= Asc("z") & Chr(13) Or (KeyAscii >= Asc("A") & Chr(13) And KeyAscii <= Asc("Z") & Chr(13) Or KeyAscii = vbKeyBack Or KeyAscii = vbKeyDelete Or KeyAscii = vbKeySpace)) Then
KeyAscii = 0
End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
InputHuruf KeyAscii
End Sub
Buat suatu project dengan :
1 Form
1 TextBox
Copy source code berikut pada Form :
Public Sub InputHuruf(ByVal KeyAscii As Integer)
If Not (KeyAscii >= Asc("a") & Chr(13) And KeyAscii <= Asc("z") & Chr(13) Or (KeyAscii >= Asc("A") & Chr(13) And KeyAscii <= Asc("Z") & Chr(13) Or KeyAscii = vbKeyBack Or KeyAscii = vbKeyDelete Or KeyAscii = vbKeySpace)) Then
KeyAscii = 0
End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
InputHuruf KeyAscii
End Sub
Tidak ada komentar:
Posting Komentar