Tutorial: Programming in Visual Basic 6.0
Tutorial: Programming in Visual Basic 6.0
Tutorial: Programming in Visual Basic 6.0
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Private Sub Command1_Click()<br />
Dim <strong>in</strong>tNumber As Integer<br />
Dim pause As Integer<br />
<strong>in</strong>tNumber = Val(Text1.Text)<br />
‘Declare variables<br />
‘Input user number<br />
If (<strong>in</strong>tNumber > 0) And (<strong>in</strong>tNumber < 11) Then ‘Validate number<br />
Do While <strong>in</strong>tNumber > 0<br />
Beep<br />
For pause = 0 To 2500<br />
‘Slow down the beeps<br />
frmBeeper.Refresh<br />
Next pause<br />
<strong>in</strong>tNumber = <strong>in</strong>tNumber - 1 ‘Count down<br />
Loop<br />
Else<br />
Text1.Text = ""<br />
Text1.SetFocus<br />
End If<br />
End Sub<br />
Write an IPO Chart for this program.<br />
Then write the pseudocode algorithm for this program.<br />
Activity 9<br />
this tutorial, we look at writ<strong>in</strong>g code conta<strong>in</strong><strong>in</strong>g the 5 basic control structures.<br />
In<br />
sequence<br />
•<br />
b<strong>in</strong>ary selection<br />
•<br />
multiway selection<br />
•<br />
pre-test iteration<br />
•<br />
post-test iteration<br />
•<br />
IPO chart and pseudocode algorithm for f<strong>in</strong>d<strong>in</strong>g the average of some numbers<br />
The<br />
from the keyboard, us<strong>in</strong>g a post-test loop, might look like this:<br />
entered<br />
number, counter<br />
I<br />
add number to sum<br />
P<br />
1 to counter<br />
add<br />
= sum/counter<br />
average<br />
O average<br />
Ma<strong>in</strong> Program<br />
BEGIN<br />
= 0<br />
counter<br />
= 0 sum<br />
REPEAT<br />
number<br />
get<br />
= sum + number<br />
sum<br />
= counter + 1<br />
counter<br />
counter = 10<br />
UNTIL<br />
= sum / counter<br />
average<br />
average<br />
display<br />
END MAINPROGRAM<br />
Write this algorithm as a flowchart.