adalah sebuah kondisi dimana satu atau beberapa kode program dieksekusi secara berulang-ulang.
Macam-macam struktur perulangan: For [var] = N awal To N akhir [step(stp)]
[statement1]
[statement2]
NextKeterangan: var = variabel yang berubah dari N awal s/d N akhir
N awal = nilai awal
N akhir = nilai akhir
Stp = besar perubahan nilaiWhile [uji kondisi]
[statement1]
[statement2]
WendDo Until [uji kondisi]
[statement1]
[statement2]
Loop
Contoh program
>> Form
>> CodePrivate Sub Command1_Click()
Dim v3 As Integer
v3 = Text1.Text
For i = 1 To v3
MsgBox i
Next
End Sub
Private Sub Command2_Click()
Dim v3 As Integer
Dim i As Integer
v3 = Text1.Text
i = 1
While i <= v3
MsgBox i i = i + 1
Wend
End Sub
Private Sub Command3_Click()
Dim v3 As Integer
Dim i As Integer
v3 = Text1.Text i = 1
Do Until i > v3
MsgBox i
i = i + 1
Loop
End Sub
Selasa, 03 Februari 2009
Fungsi Perulangan
Label:
Visual Basic
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar