|
-
Sep 26th, 2000, 10:38 AM
#1
Thread Starter
Banned
OK, I am just learning.
I want to be able to print this when
a command button is clicked:
*
**
***
****
*****
******
*******
********
*********
**********
But I have to use a ForNext Loop...
Can someone please help me?
-
Sep 26th, 2000, 10:56 AM
#2
Hyperactive Member
Why do you need a For...Next loop? Unless you need that for
a specific reason, try this
Code:
Option Explicit
Private Sub Command1_Click()
Dim i As Single, J As Single
For i = 1 To 10
For J = 1 To i
Text1.Text = Text1.Text & "*"
Next
If i <> 10 Then Text1.Text = Text1.Text & vbNewLine
Next
End Sub
-
Sep 26th, 2000, 10:59 AM
#3
Addicted Member
It's been a while since I've done this coding. This must be for school? The coding below is the ForNext loop you want, however I'm not sure if it will print the information on seperate lines. I do know you must set your textbox multiline property to true. I'm thinking this coding will work though, if not let me know, because I know I have the coding somewhere. You caught me at work without my dope books.
Dim i as integer
Dim Message as String
For i = 1 to 10 step 1
Message = Message + "*"
Next
Text1.text = Message
212 will lead you to the truth
-
Sep 26th, 2000, 11:07 AM
#4
Addicted Member
Actually it sounds like its an assigned project(school)
That would make the for next make sense. But I think he means to output into a picturebox control, hence:
'start a 10 step for next loop
For x = 1 To 10
For y = 1 To x
'print x number of stars, the ; makes it print on the same line
picbox.Print "*";
Next y
'print a blank so that it moves to the first line
picbox.Print ""
Next x
Also there are better ways to do this, but this way is low key and easy to understand
-
Sep 26th, 2000, 11:07 AM
#5
Addicted Member
DrewDog has the right idea. I know I was doing it wrong. It's been a while since I've done that one. Sorry.
212 will lead you to the truth
-
Sep 26th, 2000, 11:14 AM
#6
Thread Starter
Banned
Thank you
thanks guys! I had forgotten about printing a blank!
-
Sep 26th, 2000, 11:21 AM
#7
Fanatic Member
I think this is the shortest way:
Code:
For i = 1 to 10
Text1.Text = Text1.Text & String(i,"*") & VbCRLF
Next
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
|
Click Here to Expand Forum to Full Width
|