For Loop , For Each , Do Until
*
Public Class Form1

Private Sub clearlist()
ListBox1.Items.Clear()

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim intcount As Integer

For intcount = 1 To 9
ListBox1.Items.Add(intcount.ToString)
Next


End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
clearlist()
For Each strflder As String In My.Computer.FileSystem.GetDirectories("c:/")
ListBox1.Items.Add(strflder)
Next
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim objrandom As New Random
Dim intrandomNumber As Integer = 0
clearlist()

Do Until intrandomNumber = 10
intrandomNumber = objrandom.Next(25)
ListBox1.Items.Add(intrandomNumber.tostring)
Loop
End Sub
End Class

 

반복문의 차이 비교해 보세요

이 게시물을

공유하기

SEARCH

MENU NAVIGATION