As the previous example demonstrates, you can place control structures inside other control structures (such as an If...Then block within a For...Next loop). A control structure placed inside another control structure is said to be nested.
Control structures in Visual Basic can be nested to as many levels as you want. It’s common practice to make nested decision structures and loop structures more readable by indenting the body of the decision structure or loop.
For example, this procedure prints all the font names that are common to both the Printer and Screen:
Private Sub Form_Click()
Dim SFont, PFont
For Each SFont In Screen.Fonts()
For Each PFont In Printer.Fonts()
If SFont = PFont Then
Print SFont
End If
Next PFont
Next SFont
End Sub
No comments:
Post a Comment