Desain form seperti gambar di bawah
ketentuan
jika jumlah beli di atas 1000000 mendapatkan diskon (TextBox4) 30%
RadioButton 30% di pilih
Codng Program
Public Class Form2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox1.Focus()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Me.Close()
End Sub
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
Dim mdis As Double
TextBox3.Text = Val(TextBox1.Text) * Val(TextBox2.Text)
If TextBox3.Text > 1000000 Then
mdis = TextBox3.Text * 0.3
TextBox4.Text = mdis
RadioButton3.Checked = True
ElseIf TextBox3.Text > 500000 Then
mdis = TextBox3.Text * 0.3
TextBox4.Text = mdis
RadioButton2.Checked = True
ElseIf TextBox3.Text > 100000 Then
mdis = TextBox3.Text * 0.3
TextBox4.Text = mdis
RadioButton1.Checked = True
Else
mdis = TextBox3.Text * 0
TextBox4.Text = mdis
End If
TextBox5.Text = TextBox3.Text - mdis
End Sub
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox3.Enabled = False
TextBox4.Enabled = False
TextBox5.Enabled = False
End Sub
End Class


Posting Komentar