tutorial

Page 112

For j = 0 To i ' Second loop to count the columns star = star & " * " Next Me.stars.Text = Me.stars.Text & star & vbCrLf ' To print * star = "" Next

4. For Each…Next Statement The For Each…Next Statement is used to repeat a set of statements for each element in an array or collection. The For Each…Next statement is executed if there is at least one item in an array of collection. The Loop repeats of each element in an array or collection. The syntax for the For Each…Next statement as follows: For Each Component In Set Executable statements Next Component is the variable used to refer to the elements of an array or a collection. Set refers to an array or any collection object. e.g. Dim weeks() As String = {"Monday", "Tuesday", "Wednesday", "Thursday",_ "Friday", "Saturday", "Sunday"} Dim eachday As String For Each eachday In weeks MsgBox(eachday) Next

An example for using for each element in a collection of string into a single string element. Each element of array which is of type string is read from the collection and stored into the single string type object. 5. While…End Statement The While…End Statement is used to repeat set of executable statements as long as the condition is true. The syntax for the While…End statement is as follows: While Condition Executable Statements End While


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.