Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Start : label

Input data: Text.box


Hasil : Picture box
Do-while loop < 3 (command 1)
Do- loop while < 3 (command 2)
Do-until loop < 3 (command 3)
Do- loop until < 3 (command 4)
End (command 5)
Ulangi (command 6)




Private Sub Command1_Click()
Dim number As Integer
number = Val(Text1.Text)
Do While number < 3
Picture1.Print number
number = number + 1
Loop

End Sub

Private Sub Command2_Click()
Dim number As Integer
number = Val(Text1.Text)
Do
Picture2.Print number
number = number + 1
Loop While number < 3

End Sub

Private Sub Command3_Click()
Dim number As Integer
number = Val(Text1.Text)
Do
Picture3.Print number
number = number + 1
Loop Until number > 3

End Sub

Private Sub Command4_Click()
Dim number As Integer
number = Val(Text1.Text)
Do
Picture4.Print number
number = number + 1
Loop Until number > 3

End Sub

Private Sub Command5_Click()
End
End Sub

Private Sub Command6_Click()
txtAwal = ""
Picture1.Cls
Picture2.Cls
Picture3.Cls
Picture4.Cls

End Sub






Private Sub Command1_Click()
End
End Sub
Private Sub Command2_Click()
Picture1.Cls
If Val(Text1.Text) Mod 2 = 1 Then
Label2.Caption = "Nilai Kuadratnya ="
Picture1.Print Val(Text1.Text) ^ 2
Label3.Caption = "Bilangan Ganjil"
Else
Label2.Caption = "Nilai setengahnya"
Picture1.Print Val(Text1.Text) / 2
Label3.Caption = "Bilangan genap"
End If


End Sub

Private Sub Command3_Click()
Txt = " "
Picture1.Cls

End Sub



Private Sub Command1_Click()
End
End Sub

Private Sub Command2_Click()
Dim xlama, xbaru As Double
Dim n_iterasi, Max_iterasi As Integer
Dim kesalahan, toleransi As Double

toleransi = 0.00001
Max_iterasi = 100
xlama = Val(Text1.Text)
n_iterasi = 0
Picture2.Cls

Do
n_iterasi = n_iterasi + 1
xbaru = xlama - fungsi(xlama) /
((fungsi(xlama + 0.000003) - fungsi(xlama)) /
0.000003)
kesalahan = Abs(xlama - xbaru)
xlama = xbaru
Loop Until (kesalahan < toleransi) Or
(n_iterasi > Max_iterasi)

If n_iterasi > Max_iterasi Then
Picture2.Print "Iterasi melebihi batas
maksimum"
Picture2.Print "Solusi tidak ketemu"
Else
Picture2.Print "Hasil yang diperoleh :"
Picture2.Print "Akar persamaan = "; xbaru
Picture2.Print "dalam "; n_iterasi - 1; "
iterasi"
End If

End Sub

Private Sub Command3_Click()
Text1.Text = ""
Picture2.Cls
End Sub

Private Function fungsi(ByVal x As Double) As
Double
fungsi = 2 * x ^ 2 - 3 * x - 20
End Function

'Private Function fungsi_turunan(ByVal x As
double) As double
' fungsi_turunan = 4 * x - 3
'End Function

You might also like