CONTOH LOOPING
code untuk looping
1. Masukan code untuk CommandButton Looping
Dim Count As Integer
Dim i As Integer
Count = Val(Text1.Text)
If Count <= 0 Then
MsgBox "Nilai harus besar dari 0", vbInformation, "Error"
Else
List1.Clear
i = 0
Select Case cmbJenisLooping.ListIndex
Case 0 :
For i = 0 To Count - 1
List1.AddItem Text2.Text & " data ke - " & i + 1 & " For -- Next", i
Next i
Case 1:
While i < Count
List1.AddItem Text2.Text & " data ke - " & i + 1 & " While -- Wend", i
i = i + 1
Wend
Case Else
Do
List1.AddItem Text2.Text & " data ke - " & i + 1 & " Do -- Loop Until", i
i = i + 1
Loop Until i > Count - 1
End Select
End If
2. Masukan code untuk FormLoad
cmbJenisLooping.AddItem "For -- next"
cmbJenisLooping.AddItem "While -- wend"
cmbJenisLooping.AddItem "Do loop until"
cmbJenisLooping.ListIndex = 0
3. Masukan code untuk CommandButton Keluar
Unload Me
4. Tekan F5 untuk menjalankan program (Running)
Tidak ada komentar:
Posting Komentar