•    Coding Validasi Angka untuk menginputkan Nilai 1

Private Sub Text1_KeyPress(KeyAscii As Integer)
Const Number = "-9-8-7-6-5-4-3-2-10123456789"

If KeyAscii <> 8 And KeyAscii <> 13 Then
   If InStr(Number, Chr(KeyAscii)) = 0 Then
      KeyAscii = 0
      Exit Sub
   End If
End If
End Sub

•    Coding Validasi Angka untuk menginputkan Nilai 2

Private Sub Text2_KeyPress(KeyAscii As Integer)
Const Number = "-9-8-7-6-5-4-3-2-10123456789"

If KeyAscii <> 8 And KeyAscii <> 13 Then
   If InStr(Number, Chr(KeyAscii)) = 0 Then
      KeyAscii = 0
      Exit Sub
   End If
End If
End Sub

•    Coding Validasi Angka untuk Hasil

Private Sub Text3_KeyPress(KeyAscii As Integer)
If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = vbKeyBack Or KeyAscii = vbKeyReturn) Then KeyAscii = 0
End Sub

1 komentar:

Popular Content

 
Top