1. format Numerik dan penjunlahan sederhana dalam visual basic:
a. Buatlah 3 buah textbox( text1,text2 dan text3 )
dan masukan Koding Berikut dan tekan F5 serta lakukan penjumlahan
Private Sub Form_Load()
Text1.Text = 0
Text2.Text = 0
Text3.Text = 0
End Sub
Private Sub Text1_GotFocus()
SendKeys "{home}+{end}"
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text1.SetFocus
End If
End Sub
Private Sub Text1_LostFocus()
Text1.Text = Format(Text1.Text, "#,#")
Text3.Text = Val(Format(Text1.Text, "")) + Val(Format(Text2.Text, ""))
Text3.Text = Format(Text3.Text, "#,#")
End Sub
Private Sub Text2_GotFocus()
SendKeys "{home}+{end}"
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text2.SetFocus
End If
End Sub
Private Sub Text2_LostFocus()
Text2.Text = Format(Text2.Text, "#,#")
Text3.Text = Val(Format(Text1.Text, "")) + Val(Format(Text2.Text, ""))
Text3.Text = Format(Text3.Text, "#,#")
End Sub
Tidak ada komentar:
Posting Komentar