Public Class Form1
Private Sub btnhitung_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhitung.Click
Dim var_a, var_b, var_c, var_D, var_x1, var_x2 As Single
var_a = TextBox1.Text
var_b = TextBox2.Text
var_c = TextBox3.Text
var_D = var_b ^ 2 - (4 * var_a * var_c)
If var_D > 0 Then
var_x1 = (-var_b + Math.Sqrt(var_D)) / 2 * var_a
var_x2 = (-var_b - Math.Sqrt(var_D)) / 2 * var_a
TextBox4.Text = var_x1
TextBox5.Text = var_x2
ElseIf var_D = 0 Then
var_x1 = -var_b / 2 * var_a
var_x2 = -var_b / 2 * var_a
TextBox4.Text = var_x1
TextBox5.Text = var_x2
Else
TextBox4.Text = "Akar tidak real"
TextBox5.Text = "Akar tidak real"
End If
End Sub
Private Sub btnkeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnkeluar.Click
Close()
End Sub
End Class
Komentar
Posting Komentar