Senin, 20 Juni 2011
Visual Basic Part 12 ( Mencari Akar-akar Persamaan Kuadrat )
Private Sub CMDC_Click()
Dim a As Double
Dim b As Double
Dim c As Double
Dim D As Double
Dim r As Double
Dim z As Double
Dim z1 As Double
a = Val(TXT1.Text)
b = Val(TXT2.Text)
c = Val(TXT3.Text)
D = (b * b) - (4 * a * c)
If D = 0 Then
LBL1.Caption = -b / (2 * a)
LBL2.Caption = -b / (2 * a)
Else
If D > 0 Then
LBL1.Caption = (-b + Sqr(D)) / 2 * a
LBL2.Caption = (-b - Sqr(D)) / 2 * a
Else
z = Sqr(-D) / (2 * a)
r = -b / (2 * a)
LBL1.Caption = Format(Format(r, "##.##") & " + " & Format(z, "##.##") & "i")
LBL2.Caption = Format(Format(r, "##.##") & " - " & Format(z, "##.##") & "i")
End If
End If
End Sub
Private Sub CMDE_Click()
End
End Sub
Private Sub CMDS_Click()
TXT1.Text = ""
TXT2.Text = ""
TXT3.Text = ""
LBL1.Caption = ""
LBL2.Caption = ""
TXT1.SetFocus
End Sub
Langganan:
Posting Komentar (Atom)

Tidak ada komentar:
Posting Komentar