Tuesday, May 3, 2011

Program Perulangan Aplikasi Visual Basic


-->
Dim i As Integer
Dim j As Integer
Dim k As Double

Private Sub Command1_Click()
If Option1.Enabled = True Then

List1.Clear
j = 0
For i = 10 To 0 Step -2
If i > 0 Then
List1.AddItem i & " ."
Else
List1.AddItem i
End If
Next i

For i = -1 To -9 Step -2
If i > -9 Then
List2.AddItem i & " ."
Else
List2.AddItem i
End If
Next i

For i = 1 To 5
j = i + j
If i < 5 Then
List3.AddItem i & " + "
Else
List3.AddItem i & " = " & j
End If
Next i

For i = 10 To 50 Step 10
k = i
List4.AddItem k / 100
Next i

For i = 1 To 5
List5.AddItem "1/" & i
List8.AddItem "Formula " & i
List9.AddItem i & ". Visual Basic"
Next i

For i = 1 To 9 Step 2
List6.AddItem i & " " & i * i
Next i

For i = 50 To 10 Step -10
List7.AddItem i & " " & i / 10
Next i
ElseIf Option2.Enabled = True Then
i = 10
Do While i <= 10
If i > 0 Then
List1.AddItem i & " ."
Else
List1.AddItem i
End If
i = i - 2
If i < 0 Then
Exit Do
End If
Loop

i = -1
Do While i <= -1
If i > -9 Then
List2.AddItem i & " . "
Else
List2.AddItem i
End If
i = i - 2
If i < -9 Then
Exit Do
End If
Loop

i = 1
j = 0
Do While i >= 1
j = i + j
If i < 5 Then
List3.AddItem i & " + "
Else
List3.AddItem i & " = " & j
End If
i = i + 1
If i > 5 Then
Exit Do
End If
Loop
i = 10
Do While i >= 10
k = i
List4.AddItem k / 100
i = i + 10
If i > 50 Then
Exit Do
End If
Loop

i = 1
Do While i >= 1
List5.AddItem "1/" & i
List8.AddItem "Formula " & i
List9.AddItem i & ". Visual Basic"
i = i + 1
If i > 5 Then
Exit Do
End If
Loop

i = 1
Do While i >= 1
List6.AddItem i & " " & i * i
i = i + 2
If i > 9 Then
Exit Do
End If
Loop

i = 50
Do While i <= 50
List7.AddItem i & " " & i / 10
i = i - 10
If i = 0 Then
Exit Do
End If
Loop
ElseIf Option3.Enabled = True Then
i = 10
Do Until i < 0
If i > 0 Then
List1.AddItem i & " ."
Else
List1.AddItem i
End If
i = i - 2
Loop

i = -1
Do Until i <= -11
If i > -9 Then
List2.AddItem i & " . "
Else
List2.AddItem i
End If
i = i - 2
Loop

i = 1
j = 0
Do Until i >= 6
j = i + j
If i < 5 Then
List3.AddItem i & " + "
Else
List3.AddItem i & " = " & j
End If
i = i + 1
Loop

i = 10
Do Until i >= 60
k = i
List4.AddItem k / 100
i = i + 10
Loop

i = 1
Do Until i >= 6
List5.AddItem "1/" & i
List8.AddItem "Formula " & i
List9.AddItem i & ". Visual Basic"
i = i + 1
Loop

i = 1
Do Until i >= 10
List6.AddItem i & " " & i * i
i = i + 2
Loop

i = 50
Do Until i <= 0
List7.AddItem i & " " & i / 10
i = i - 10
Loop
Else
MsgBox "Anda belum memilih opsi"
End If
End Sub

Private Sub Command2_Click()
Unload Me
Form1.Show
End Sub

Private Sub Option1_Click()
If Option1.Enabled = True Then
List1.Clear
List2.Clear
List3.Clear
List4.Clear
List5.Clear
List6.Clear
List7.Clear
List8.Clear
List9.Clear
End If
End Sub

Private Sub Option2_Click()
If Option2.Enabled = True Then
List1.Clear
List2.Clear
List3.Clear
List4.Clear
List5.Clear
List6.Clear
List7.Clear
List8.Clear
List9.Clear
End If
End Sub

Private Sub Option3_Click()
If Option3.Enabled = True Then
List1.Clear
List2.Clear
List3.Clear
List4.Clear
List5.Clear
List6.Clear
List7.Clear
List8.Clear
List9.Clear
End If
End Sub

0 komentar:

Post a Comment

Tinggalkan Komentar Disini