ga usah pake msgbox, langsung kunci aja textboxnya hanya bisa diisi
angka
private sub txt1_keypress(keyascii as integer)
Dim Key As String
Key = "1234567890"
If KeyAscii > 26 Then
If InStr(kepres, Chr(KeyAscii)) = 0 Then
KeyAscii = 0
End If
End If
End sub
Masukkan variable key, angka-angka yang hanya boleh di input
Regards
Priyo
-----Original Message-----
From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of mario
Sent: Wednesday, January 16, 2008 7:18 PM
To: [email protected]
Subject: [Programmer-VB] validasi lagi nih,, logika nya ga nemu
Permisi semua nya.
Saya minta bantuan temen-temen sekalian,
Saya mw validasi agar input hanya berupa angka!
Ato berupa "tombol enter"
Sedikit codingnya:
Private Sub Text3_Keypress(KeyAscii As Integer)
If (Not KeyAscii >= Asc("0") Or Not KeyAscii <= Asc("9")) _
Or KeyAscii <> Asc(vbBack) Or Not KeyAscii = 13 Then
MsgBox "Input harus berupa angka", vbOKOnly, "Warning"
Text3.Text = ""
End If
If KeyAscii = 13 Then
Command1.SetFocus
End If
End Sub
Bagaimana yah???
Klo pake coding ini, walaupun input nya = angka 0-9
Tetap akan menuju msgbox.
Trima kasih buat pencerahannya