Wednesday, December 25, 2013

Pembulatan angka di vb6


Step 1 : Buatlah Function dengan kode sebagai berikut
Private Function Genapkan(ByVal Number As Double, Optional Range = 100) As Double
  Genapkan = (Round((Number / Range) + 0.49)) * Range
End Function

Step 2 : Ketikan Kode pada Keypress di TextBox Gaji Pokok
Private Sub txt_gapok_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
   KeyAscii = 13
   txt_tjkes = Genapkan(txt_gapok.Value / 12)
txt_tjjab.SetFocus
End If
End Sub

sourcode bisa di download disini 

0 comments:

Post a Comment