PDA

Click to See Complete Forum and Search --> : problem with nested counter controlled repetition


conyers
Nov 19th, 2000, 12:01 AM
The following code:

Private Sub cmdPrint_Click()
Dim count As Integer
Dim number As Integer
Dim counter As Integer

count = 1
number = 0
counter = 0

For count = 1 To 10
Do
Print "*"
number = number + 1
counter = counter + 1
Loop While number <> counter
Print
Next count

End Sub

is supposed to produce the following shape:

*
**
***
****
*****
******
*******
********
*********
**********

Instead it produces thus:

*
*
*
*
*
*
*
*
*
*

please help.

Bjwbell
Nov 19th, 2000, 01:41 AM
Here's some coed that does what you want
The reason your code can't produce the correct result is because every time you print"* in goes down one line

Private Sub Command1_Click()

Dim count As Integer




For count = 1 To 10
Select Case count
Case 1
Print "*"
Case 2
Print "**"
Case 3
Print "***"
End Select
Next count


End Sub

tumblingdown
Nov 19th, 2000, 04:15 AM
Dim i%

For i = 1 To 10
Print String(i, "*")
Next


td.

tumblingdown
Nov 19th, 2000, 04:17 AM
and why is this in chit-chat?


td.