-
help please
aprogram using while loops or for loops to draw a christmas atree ,such as :
*
***
*****
* has box for the tree
Draw at least 10 levels of the tree , increasing the size of each level. ( space between each asterisk for visbility is optional )
-
What problem are you having? Please post the code you have so far.
Phil Weber
http://www.philweber.com
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
-
Methinks I smell a student project...
Bob Rouse
Dimension Data
-
this my code but will looks like the first one
what I need is to be looks like TREE !!
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btntree.Click
Dim i, j As Integer
Dim raw As String
For i = 1 To 12
raw = " "
For j = 1 To i
raw &= "*"
Next
Lsttree.Items.Add(raw)
Next
End Sub
-
You need to add something akin to:
raw = Space((12 - i) / 2) & raw & Space((12 - i) / 2)
after the inner loop (the first "Next")
Bob Rouse
Dimension Data
-
Try this:
Code:
Dim i, j As Integer
Dim raw As String
For i = 1 To 24 Step 2
raw = ""
For j = 1 To i
raw &= "*"
Next
raw = Space((24 - i) \ 2) & raw
Lsttree.Items.Add(raw)
Next
Phil Weber
http://www.philweber.com
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
-
THANKSSS ALOTSSSSS .... it work
i was trying to do it in long way but this 's easier 
HAVE AGREAT WEEKEND
-
The important thing, though, is do you understand why it works? ;-)
Phil Weber
http://www.philweber.com
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
-
yeahhhh i understood
-
not to sound peeky (please correct my spelling), but because this is a "learning" thread:
The code
Code:
raw = ""
For j = 1 To i
raw &= "*"
Next
can be replaced with:
raw = String(i, "*")
Marco
"There are two ways to write error-free programs. Only the third one works."
Unknown
-
THankkkkkkkkkkk you agin
-
Marco: Except that his assignment specifically said to use "while loops or for loops." ;-)
Phil Weber
http://www.philweber.com
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
-
I know, but I could not resist... there is an outer loop anyway!
To the original poster: you can change the space between asterisks printing directly in the Form via
Me.Print "*"
This prints an asterisk at the coordinates:
Me.CurrentX
Me.CurrentY
To find the size of a string you can use:
Me.TextWidth
Me.TextHeight
And remember to do your drawing in the Form_Paint event.
That is enough for today, I think.
Marco
"There are two ways to write error-free programs. Only the third one works."
Unknown
-
lol .... thank you so much PHil and Macro.
I learned from both of you new things
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks