Tutorial
Komponen
|
Properties
|
Keterangan
|
Form1
|
Name
Text
|
Form1
Form1
|
Label1
|
Name
Text
|
Label1
Mencari Akar Fungsi Kuadrat
|
Label2
|
Name
Text
|
Label2
X^2
|
Label3
|
Name
Text
|
Label3
X
|
Label4
|
Name
Text
|
Label4
X1
|
Label5
|
Name
Text
|
Label5
X2
|
Button1
|
Name
Text
|
Button1
Lihat
|
Textbox1
|
Name
Text
|
Textbox1
|
Textbox2
|
Name
Text
|
Textbox2
|
Textbox3
|
Name
Text
|
Textbox3
|
Textbox4
|
Name
Text
|
Textbox4
|
Textbox5
|
Name
Text
|
Textbox5
|
listing:
Public Class Form1
Dim a As
Double
Dim b As
Double
Dim c As
Double
Dim d As
Double
Dim x1 As
Double
Dim x2 As
Double
Private Sub
Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
Me.BackColor
= Color.BurlyWood
TextBox4.Enabled = False
TextBox5.Enabled = False
End Sub
Private Sub
Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
If
TextBox2.Text = "" Or TextBox3.Text = ""
Then
MsgBox("Belum
lengkap mengisi")
ElseIf
TextBox1.Text = "0" Or TextBox1.Text = ""
Then
a = 1
b = Val(TextBox2.Text)
c = Val(TextBox3.Text)
d = ((b ^ 2) - (4 * a * c))
x1 = (((-b) + Math.Sqrt(d)) / (2 * a))
x2 = (((-b) - Math.Sqrt(d)) / (2 * a))
Else
a = Val(TextBox1.Text)
b = Val(TextBox2.Text)
c = Val(TextBox3.Text)
d = ((b ^ 2) - (4 * a * c))
x1 = (((-b) + Math.Sqrt(d)) / (2 * a))
x2 = (((-b) - Math.Sqrt(d)) / (2 * a))
End If
Me.TextBox4.Text
= x1
Me.TextBox5.Text
= x2
End Sub
Private Sub
TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
TextBox4.TextChanged
End Sub
Private Sub
TextBox5_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
TextBox5.TextChanged
End Sub
Private Sub
Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button2.Click
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
End Sub
End Class
Tidak ada komentar:
Posting Komentar