1. Private Sub CommandButton1_Click()
a = Val(TextBox1)
b = Val(TextBox2)
c = b - a
d = c / a * 100 & "%"
If c > 0 Then
Label3.Caption = "Untung"
Label4.Caption = "Persentase Untung"
TextBox3 = c
TextBox4 = d
Else
If c < 0 Then
Label3.Caption = "Rugi"
Label4.Caption = "Persentase Rugi"
TextBox3 = Abs(c)
TextBox4 = (-1) * c / a * 100 & "%"
Else
Label3.Caption = "Untung / Rugi"
Label4.Caption = "Persentase Untung / Rugi"
TextBox3 = c
TextBox4 = d
End If
End If
End Sub
Private Sub CommandButton2_Click()
TextBox1 = Empty
TextBox2 = Empty
TextBox3 = Empty
TextBox4 = Empty
End Sub