Berikut adalah source code vb.6 agar textbox hanya menerima input angka. Cocok digunakan untuk input kode pos atau no telepon.
Siapkan :
1 Form
1 TextBox
Source Code :
Public Sub HanyaAngka(ByRef KeyAscii As Integer)
If ((KeyAscii < 48 And KeyAscii <> 8 ) Or KeyAscii > 57) Then
KeyAscii = 0
End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
HanyaAngka KeyAscii
End Sub
If ((KeyAscii < 48 And KeyAscii <> 8 ) Or KeyAscii > 57) Then
KeyAscii = 0
End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
HanyaAngka KeyAscii
End Sub
Sekian, smoga manfaat... :)
0 komentar:
Posting Komentar