Rabu, 05 Oktober 2011

LOOPING

Looping dengan menggunakan dengan "DO WHILE".....
Seperti biasa pertama kita masuk ke dalam  microsoft visual basic 6.0..
kemudian buat seperti gambar di bawah:


lalu edit captionnya, seperti :

terus edit jga back colornya jadinya kaya gini :


lalu masukin deh coding nya :
"Private Sub Command1_Click()
n = Val(Text1)
Do While i <= n
If i Mod 2 = 0 Then
List1.AddItem 1
Else
List1.AddItem -1
End If
i = i + 1

Private Sub Command2_Click()
Dim i, n As Integer
i = 1
a = 2
n = Val(Text2)
Do While i <= n
If i Mod 2 = 0 Then
List2.AddItem -a
Else
List2.AddItem a

End If
i = i + 1
a = a + 2
Loop
End Sub


Private Sub Command3_Click()
Dim a As Integer
a = 1
i = 1
n = Val(Text3)
Do While i <= n
List3.AddItem a
If a = 2 Then
a = 3
Else
a = a + 3
i = i + 1
End If

Loop

End Sub




Private Sub Command4_Click()
i = 1
a = 2
n = Val(Text4)
Do While i <= n
List4.AddItem a
a = a * a
i = i + 1
Loop
End Sub"





Terus play hasil nya kaya gini:





okey...
selamat mencoba..
(",)..


Tidak ada komentar:

Posting Komentar