Syntax di button proccess
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'deklarasi variabel
Dim a, b, c, d As Decimal
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Then
MessageBox.Show("Nilai A, B, dan C tidak boleh kosong", "Peringatan")
Else
'input
a = CDec(TextBox1.Text)
b = CDec(TextBox2.Text)
c = CDec(TextBox3.Text)
'mencari determinan
d = b ^ 2 - 4 * a * c
If d > 0 Then
TextBox4.Text = CStr((-b + Math.Sqrt(d)) / 2 * a)
TextBox5.Text = CStr((-b - Math.Sqrt(d)) / 2 * a)
TextBox6.Text = "Akar Berlainan"
ElseIf d = 0 Then
TextBox4.Text = CStr(-b / 2 * a)
TextBox5.Text = CStr(-b / 2 * a)
TextBox6.Text = "Akar Kembar"
Else
TextBox4.Text = 0
TextBox5.Text = 0
TextBox6.Text = "Akar Imaginer"
End If
End If
End Sub
Tidak ada komentar:
Posting Komentar