contoh 1 :
Private Sub Text2_KeyPress(KeyAscii As Integer) KeyAscii = Asc(UCase(Chr(KeyAscii))) End SubContoh 2 :
Public Function CapitalLetter(objectToIgnore As TextBox) objectToIgnore.Text = UCase(objectToIgnore.Text) objectToIgnore.SelStart = Len(objectToIgnore) End Function Private Sub Text1_Change(Index As Integer) Select Case Index Case 0 objects = CapitalLetter(Text1(0)) Case 1 objects = CapitalLetter(Text1(1)) End Select End Sub
Berikut contoh hanya angka yang boleh diinput:
Private Sub Text1_KeyPress(KeyAscii As Integer) 'hanya dapat diisi angka 0 - 9 If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = vbKeyBack) Then KeyAscii = 0 End SubBerikut contoh hanya huruf yang boleh diinput:
Public Sub Huruf(ByRef KeyAscii As Integer) If Not (KeyAscii >= Asc("a") & Chr(13) And KeyAscii <= Asc("z") & Chr(13) Or (KeyAscii >= Asc("A") & Chr(13) And KeyAscii <= Asc("Z") & Chr(13) Or KeyAscii = vbKeyBack Or KeyAscii = vbKeyDelete Or KeyAscii = vbKeySpace)) Then KeyAscii = 0 End If End Sub Private Sub Text1_KeyPress(KeyAscii As Integer) Huruf KeyAscii End Sub
0 komentar:
Posting Komentar