


Public Sub HanyaHuruf(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)
HanyaHuruf KeyAscii
End Sub

Public Function HanyaAngka(ByVal kode As String) As Boolean
If (kode >= 48 And kode <= 57) Or kode = 8 Then
HanyaAngka = False
Else
HanyaAngka = True
End If
End Function
Private Sub txtTahunTerbit_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtTahunTerbit.KeyPress
e.Handled = HanyaAngka(Asc(e.KeyChar))
End Sub



Users browsing this forum: No registered users and 8 guests