Projemize 3 adet text ve 1 adet command ekleyip aşağıda ki kodları yazalım
Kod: Kodu kopyalamak için üzerine çift tıklayın!
Public Function dblRoundOff(ByVal x As Double, ByVal N As Integer) As Double
dblRoundOff = CDbl(Int((x * 10 ^ N) + 0.5) / 10 ^ N)
End Function
Private Sub Command1_Click()
t1 = Round((Text1 * 10000), 2) * 100
t1 = dblRoundOff(t1, 2)
t2 = Round((Text2 * 10000), 2) * 100
t2 = dblRoundOff(t2, 2)
t3 = Val(t1) + Val(t2)
t4 = (Round((Val(t3) / 10000), 2) / 100)
t4 = dblRoundOff(t4, 2)
Text3.Text = t4
Text3.Text = Format(Text3.Text, "###,###.00 YTL")
Text1.Text = Format(Text1.Text, "###,###.00 YTL")
Text2.Text = Format(Text2.Text, "###,###.00 YTL")
End Sub
Private Sub Text1_GotFocus()
If Text3.Text <> "" Then
Text1 = ""
Text2 = ""
Text3 = ""
End If
End Sub
Private Sub Text2_GotFocus()
If Text3.Text <> "" Then
Text1 = ""
Text2 = ""
Text3 = ""
End If
End Sub