QB64 Phoenix Edition
request for printing patterns with for loops tutorial - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: Official Links (https://qb64phoenix.com/forum/forumdisplay.php?fid=16)
+--- Forum: Learning Resources and Archives (https://qb64phoenix.com/forum/forumdisplay.php?fid=13)
+--- Thread: request for printing patterns with for loops tutorial (/showthread.php?tid=3219)

Pages: 1 2 3


RE: request for printing patterns with for loops tutorial - fistfullofnails - 08-14-2025

OK, I think this is how to spoonfeed a dummy like me.

[qb][FOR count% = 1 TO 4
    PRINT STRING$(5, "*")
NEXT/qb]

I thank an earlier comment that turned me on to STRING$.  Although I will say there are some pretty cool solutions here, even though I don't understand them all. And I guess I need to learn how to insert code again.


RE: request for printing patterns with for loops tutorial - fistfullofnails - 08-14-2025

So using what I figured here months later, I came up with this for a tree

Code: (Select All)
DIM spaces%
DIM n%
spaces% = 20
n% = 1

PRINT
PRINT


FOR count% = 1 TO 20
    PRINT STRING$(spaces%, " ");
    PRINT STRING$(n%, "*")
    spaces% = spaces% - 1
    n% = n% + 2
NEXT
spaces% = 18
FOR count% = 1 TO 2
    PRINT STRING$(spaces%, " ");
    PRINT STRING$(4, "|")
NEXT
I guess I'll have to get on you other fine folk's level to be able to turn my tree into a Christmas tree though.  That could very well never happen though.


RE: request for printing patterns with for loops tutorial - bplus - 08-15-2025

Code: (Select All)
Dim spaces%
Dim n%
spaces% = 20
n% = 1

Print
Print


For count% = 1 To 20
    Print String$(spaces%, " ");

    'Print String$(n%, "*")
    For i = 1 To n%
        Color Int(Rnd * 15) + 1
        Print "*";
    Next
    Print

    spaces% = spaces% - 1
    n% = n% + 2
Next
spaces% = 18
For count% = 1 To 2
    Print String$(spaces%, " ");
    Print String$(4, "|")
Next



RE: request for printing patterns with for loops tutorial - fistfullofnails - 08-19-2025

(08-15-2025, 12:20 AM)bplus Wrote:
Code: (Select All)
Dim spaces%
Dim n%
spaces% = 20
n% = 1

Print
Print


For count% = 1 To 20
    Print String$(spaces%, " ");

    'Print String$(n%, "*")
    For i = 1 To n%
        Color Int(Rnd * 15) + 1
        Print "*";
    Next
    Print

    spaces% = spaces% - 1
    n% = n% + 2
Next
spaces% = 18
For count% = 1 To 2
    Print String$(spaces%, " ");
    Print String$(4, "|")
Next
Code: (Select All)
Print "But how?"



RE: request for printing patterns with for loops tutorial - bplus - 08-19-2025

But how what?

You don't want a tree all lit up with different colors, as my code mod of yours does?