-
im trying to make this print out by using nested For/Next loops. I can do it with out them but it is more work and doesnt seem necessary..
* ********** ********** *
** ********* ********* **
*** ******** ******** ***
**** ******* ******* ****
***** ****** ****** *****
****** ***** ***** ******
******* **** **** *******
******** *** *** ********
********* ** ** *********
********** * * **********
-
You could use:
Code:
Dim intIndex As Integer
For intIndex = 1 To 10
Print String(intIndex, "*") & " " & String(11 - intIndex, "*") & " " & String(11 - intIndex, "*") & " " & String(intIndex, "*")
Next intIndex
That uses minimal code, but doesn't use nested loops. If you really wanted to use nested loops (and more code) you could do:
Code:
Dim intOuter As Integer
Dim intInner As Integer
For intOuter = 1 To 10
For intInner = 1 To intOuter
Print "*";
Next intInner
Print " ";
For intInner = 1 To 11 - intOuter
Print "*";
Next intInner
Print " ";
For intInner = 1 To 11 - intOuter
Print "*";
Next intInner
Print " ";
For intInner = 1 To intOuter
Print "*";
Next intInner
Print
Next intOuter
Paul
PS = paulw: *chuckle* :)
[Edited by PWNettle on 11-22-2000 at 11:46 AM]
-
Use symmetry.
Code:
For i = 1 To 10
strToPrint = ""
For j = 1 To i
strToPrint = strToPrint & "*"
Next j
strToPrint = strToPrint & " "
For j = 1 To 11 - i
strToPrint = strToPrint & "*"
Next j
strToPrint = strToPrint & " "
For j = 1 To 11 - i
strToPrint = strToPrint & "*"
Next j
strToPrint = strToPrint & " "
For j = 1 To i
strToPrint = strToPrint & "*"
Next j
Debug.Print strToPrint
Next i
OK?
P.
edit: Hey PWNettle - great minds think alike!!!
[Edited by paulw on 11-22-2000 at 11:01 AM]