coba yang ini :
   
  Private Function ValidAngka(ByVal KeyAscii As Integer) As Integer
    Dim strValid As String
    
    strValid = "0123456789"
    If InStr(strValid, Chr(KeyAscii)) = 0 And Not (KeyAscii = vbKeyBack) Then
        ValidAngka = 0
    Else
        ValidAngka = KeyAscii
    End If
End Function
   
  Private Function ValidHuruf(ByVal KeyAscii As Integer) As Integer
    If Not ((KeyAscii >= Asc("A") And KeyAscii <= Asc("Z")) Or (KeyAscii >= 
Asc("a") And KeyAscii <= Asc("z")) Or _
            KeyAscii = Asc("&") Or KeyAscii = vbKeyBack Or KeyAscii = 
vbKeySpace) Then
        ValidHuruf = 0
    Else
        ValidHuruf = KeyAscii
    End If
End Function
   
  Private Sub txtInputAngka_KeyPress(KeyAscii As Integer)
    KeyAscii = ValidAngka(KeyAscii)
End Sub
   
  Private Sub txtInputHuruf_KeyPress(KeyAscii As Integer)
    KeyAscii = ValidHuruf(KeyAscii)
End Sub
  
Private Sub Form_Load()
    'membatasi maksimal input, bisa juga diset lewat properties pada saat design
    txtInputAngka.MaxLength = 5
End Sub
   
  selamat mencoba :)
wijdan ibn masood <[EMAIL PROTECTED]> wrote:
          Mo tanya...
Gmn cara (kodenya) supaya input pd textbox hanya bisa angka, tdk bs huruf dan 
dibatasi, misalnya hanya bisa 5 angka/digit?
dan sebaliknya, hanya bisa huruf, tdk bisa angka?

Tq

Wijdan

---------------------------------
Be a better Globetrotter. Get better travel answers from someone who knows.
Yahoo! Answers - Check it out.

[Non-text portions of this message have been removed]



         

 
---------------------------------
We won't tell. Get more on shows you hate to love
(and love to hate): Yahoo! TV's Guilty Pleasures list.

[Non-text portions of this message have been removed]

Kirim email ke