Visual basic control flow structure and uses of each

Asked By 30 points N/A Posted on -
qa-featured

Hello!

I want to know what are the different control flow structure. Is there any sub categories for each? What are the different operators that I can use and what are the description? Can you show me how to implement the control flow structure? How to properly declare it to my programs? What are the other controls I can use to make it work properly and interactive? Please provide me explanation if you have to show declarations/syntaxes for this. Thank you and have a nice day!

SHARE
Answered By 0 points N/A #165321

Visual basic control flow structure and uses of each

qa-featured

Hello Marie!

1. Sequence – executes lines of code in the order in which they are written

2. Selection – enables you to selectively execute one part of the program instead of another.

2.a. If/Then Statement

2.b. If/Then Else Statement

2.c. Nested If

2.d. Select Case

3. Repetitions – provide a means to repeat certain parts of a program.

3.a. Do While Loop

3.b. Do Until Loop

3.c. Do Loop Until

3.d. For Loop

4. The operators that we can use in VB or any programming language are Addition, Subtraction, Division(float “/”)-use to return fractional or decimal places, Division(integer “”)-use to return whole values only, Exponentiation (caret “^”)-raise a value to a power, and Modulus division (Mod)- this is used to divide numbers and return only the remainder.

Example: Let’s say we have form, command button and textbox. We will test the value of the textbox if it is “0” or “1”

Place all the objects we need for this. Click commandbutton1 and change its name to cmdTest. Double click cmdTest.

Line 1: Private sub cmdTest_Click()

Line 2: If text1=”0” then

Line 3: MsgBox “You entered 0 (zero)”

Line 4: End if

Line 5: End Sub

Ignore lines 1 and 5. Focus on lines 2-4. Line 2 will determine if you entered “0” – it will display the message in line 3. If you did not place anything (no value entered) or any characters or number it will not display anything only if you enter the proper number that will satisfy the statement.

Login/Register to Answer

Related Questions