Jump to content
Sign in to follow this  
mus3na

Text Box In Vb 6

Recommended Posts

Assalammualaikum dan salam sejahtera.

ni nak tanya lai ni, puas gak aku semak2 ebook and carik kat google tapi tak jumpa apa yg aku nak. so tanya kat sini mana tau ada user yg ada pengalaman ngan masalah yg sama ngan aku.

aku nak set text box dalam application aku (vb6 app) supaya hanya accept integer data. normal text box accept apa2 (text or number). kat text box properties tu aku dah set data type = Number. tapi bila run program aku still boleh masukkan text kat dalam box tu.

aku ada jumpa program base on vb 6 yg org lain buat. kat text box dia, kalau aku try nak key in text, nothing happen. hanya bila aku key in number baru number tu masuk kedalam text box.

so sapa tau camana nak jadikan text box ni macam diatas? pening dah aku.

Share this post


Link to post
Share on other sites

w'salam

Private Sub Text1_KeyPress(KeyAscii As Integer)
    If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 8 Then
    Else
        KeyAscii = 0 
    End If
End Sub

Remark :

keyascii 48 = 0

keyascii 49 = 1

....

keyascii 57 = 9

keyascii 8 = BackSpace

Share this post


Link to post
Share on other sites

cun la naga, aku dah try, memang jadi sebijik cam yg aku nak. satu lai nak tanya, ASCII code ni sama ke ngan mana2 ascii code yg ada dalam lampiran buku2 programming or buku E&E

Share this post


Link to post
Share on other sites

cun la naga, aku dah try, memang jadi sebijik cam yg aku nak. satu lai nak tanya, ASCII code ni sama ke ngan mana2 ascii code yg ada dalam lampiran buku2 programming or buku E&E

Sama x salah aku... cam keyascii 13 = enter..

ko nak tau keyascii utk char, pakai je code asc(Huruf/nombor)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...