Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 6 Controlling Program Flow with Looping Structures.

Similar presentations


Presentation on theme: "Chapter 6 Controlling Program Flow with Looping Structures."— Presentation transcript:

1 Chapter 6 Controlling Program Flow with Looping Structures

2 6.1 The Do…Loop Statement Is a looping structure that executes a set of statements as long as a condition is True. Iteration – repeating one or more statements Example: Dim intNum As Integer intNum = 0 Do intNum = intNum + 2 ‘ Increment by 2 Loop While intNum < 10 (Do…Loop executes five times, on the fifth time Intnum = 10 making the condition false)

3 Do…Loop While The code in the loop must be executed at least once The condition determines if the loop will be repeated (True it repeats False it leaves the loop and continue on with the program).

4 Do While …Loop Different than the Do…Loop While The condition is evaluated first before entering the loop. If condition evaluates true the loop is entered. If the condition evaluates to false the loop is skipped. The code in the loop is not guarantee to be execute at all.

5 6.2 Infinite Loops Is a loop that does not stop running and never becomes false. CTRL + BREAK will stop an infinite loop if one occurs

6 6.3 Input Boxes Is a Visual Basic predefined dialog box that has a prompt, a text box, and OK and Cancel buttons. Used to get information from the user.

7 Input Boxes The InputBox form is –InputBox(prompt, title) –Prompt represents a string –Title represents a string –The InputBox will return a string so you will need to have a String memory variable to hold it or you can display it with the label.

8 Example of Code for the InputBox Dim strTextInput As String strTextInput = InputBox(“Enter Text”, “Input Box”) Or lblLabel.Caption = InputBox(“Enter text”, “Input Box”)


Download ppt "Chapter 6 Controlling Program Flow with Looping Structures."

Similar presentations


Ads by Google