Sabtu, 04 Desember 2010

Contoh Program Looping Sederhana Visual Basic



1. Looping dengan output :

















Kode pada Command Button:

Private Sub Command1_Click()
For y = 1 To Text1.Text
For x = 1 To y
Print y;
Next y
Print
Next
End Sub


2. Looping dengan output : 


















Kode pada Command Button:

Private Sub Command1_Click()
For y = 1 To Text1.Text
For x = 1 To y
Print x;
Next y
Print
Next
End Sub


3. Looping dengan Output :


















Kode pada Command Button:

Private Sub Command1_Click()
For y = Text1.Text To 1 Step -1
For x = 1 To y
Print y;
Next y
Print
Next
End Sub


4. Looping dengan Output :


















Kode pada Command Button:

Private Sub Command1_Click()
For y = Text1.Text To 1 Step -1
For y = 1 To y
Print x;
Next y
Print
Next
End Sub


5. Looping dengan Output :

Kode pada Command Button:

Private Sub Command1_Click()
For a = 1 To Val(Text1.Text) - 1
For b = 1 To a
Print b;
Next b
Print
Next
For c = Text1.Text To 1 Step -1
For d = 1 To c
Print d;
Next d
Print
Next
End Sub


6. Looping dengan Output :


Kode pada Command Button:

Private Sub Command1_Click()
For a = 1 To Val(Text1.Text) - 1
For b = 1 To a
Print a;
Next b
Print
Next
For c = Text1.Text To 1 Step -1
For d = 1 To c
Print c;
Next d
Print
Next
End Sub


2 komentar:

  1. 12345678
    23456781
    34567812
    45678123
    ..........


    kalau buat yang kayak gini, syntagnya gimana ?
    Please Help me...

    BalasHapus
  2. kalau buat gini gimana ya
    *2 3 4 *
    *7 8 9 *
    *12 13 14 *
    * 17 19 19 *
    * 22 23 24 *
    dst.
    mohon bantuannya

    BalasHapus

Tulis Komentar Disini