b. Desain Text Boxt


Menghindari input karakter tertentu pada textbox.
Persiapan: 1. Buat 1 Project baru dengan 1 Form dan 1 TextBox.
2. Copy-kan coding berikut ke dalam editor form ybt.

-------------------------------------------------------------------

Listing Program :
Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim sTemplate As String
'Ganti '!@#$%^&*()_+=' dengan karakter yang Anda inginkan untuk
'dihindari diinput pada Text1
sTemplate = "!@#$%^&*()_+="
If InStr(1, sTemplate, Chr(KeyAscii)) > 0 Then KeyAscii = 0
End Sub

====================================================================
Hanya tipe data number/numeric yang boleh dientri ke dalam textbox.

Persiapan: 1. Buat 1 Project baru dengan 1 Form, 2 TextBox.
2. Copy-kan coding berikut ke dalam editor yang bertalian.
--------------------------------------------------------------------

Lisitng Program :
'Hanya karakter 0 sampai dengan 9 saja.
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii < 47 Or KeyAscii > 57 Then KeyAscii = 0
End Sub

'Cara di atas hanya menerima karakter 0 sampai dengan 9 saja.
'Agar tombol lainnya seperti Delete, BackSpace, dan SpaceBar
'juga bisa diterima, Anda bisa menggunakan tips di bawah ini:
Private Sub Text2_KeyPress(KeyAscii As Integer)
If Not (KeyAscii >= Asc("0") & Chr(13) _
And KeyAscii <= Asc("9") & Chr(13) _
Or KeyAscii = vbKeyBack _
Or KeyAscii = vbKeyDelete _
Or KeyAscii = vbKeySpace) Then
Beep
KeyAscii = 0
End If
End Sub
 
What is New ?
 
Thank You Myspace Comments
DOWNLOAD :
 
E-LEARNING :
 
HIBURAN :
 
 
Today, there have been 1 visitors (1 hits) on this page!
This website was created for free with Own-Free-Website.com. Would you also like to have your own website?
Sign up for free