Chapter 7 Quick Reference


Chapter 7 Quick Reference

To

Do this

Execute a group of program statements a specific number of times

Insert the statements between For and Next statements in a loop. For example:

Dim i As Integer For I = 1 To 10      MsgBox("Press OK already!") Next i

Use a specific sequence of numbers with statements

Insert the statements in a For…Next loop, and use the To and Step keywords to define the sequence of numbers. For example:

Dim i As Integer For i = 2 To 8 Step 2     TextBox1.Text = TextBox1.Text & i Next I

Avoid an endless Do loop

Be sure the loop has a test condition that can evaluate to False.

Exit a For…Next loop prematurely

Use the Exit For statement. For example:

Dim InpName As String  Dim i As Integer  For i = 1 To 10      InpName = InputBox("Name?")      If InpName = "Trotsky" Then Exit For      TextBox1.Text = InpName  Next i

Execute a group of program statements until a specific condition is met

Insert the statements between Do and Loop statements. For example:

Dim Query As String = ""  Do While Query <> "Yes"      Query = InputBox("Trotsky?")      If Query = "Yes" Then MsgBox("Hi") Loop

Loop until a specific condition is True

Use a Do loop with the Until keyword. For example:

Dim GiveIn As String  Do      GiveIn = InputBox("Say 'Uncle'") Loop Until GiveIn = "Uncle"

Loop for a specific period of time in your program

Use the Timer control.

Insert a code snippet into your program

In the Code Editor, position the insertion point (I-beam) at the location where you want to insert the snippet. On the Edit menu, click Intelli-Sense, and then click Insert Snippet. Browse to the snippet that you want to use, and then double click the snippet name.

Add or reorganize snippets in the Insert Snippet list box

Click the Code Snippet Manager command on the Tools menu.



Microsoft Visual Basic 2005 Step by Step
Microsoft Visual Basic 2005 Step by Step (Step by Step (Microsoft))
ISBN: B003E7EV06
EAN: N/A
Year: 2003
Pages: 168

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net