473,378 Members | 1,309 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

HI i need some help with looping

1
I am creating a Number Generator program and it needs to look similar to this:

1
2 2
3 3 3
4 4 4 4

The user inputs the number of rows. I have no idea how to space out my numbers in order for that to look like a piramid. The code I have so far is:

Private Sub cmdShowTable_Click()

Dim a As String
Dim num As Integer
Me.Cls

num = txtInput.Text

For i = 1 To num
a = ""
For j = 1 To i
a = a & " " & i
Next j
Print a
Next i

End Sub

Please Help!
Oct 11 '06 #1
1 977
willakawill
1,646 1GB
I am creating a Number Generator program and it needs to look similar to this:

1
2 2
3 3 3
4 4 4 4

The user inputs the number of rows. I have no idea how to space out my numbers in order for that to look like a piramid. The code I have so far is:

Private Sub cmdShowTable_Click()

Dim a As String
Dim num As Integer
Me.Cls

num = txtInput.Text

For i = 1 To num
a = ""
For j = 1 To i
a = a & " " & i
Next j
Print a
Next i

End Sub

Please Help!
This will work:

For i = 1 To num
a = i
j = 1
Do While j < i
a = a & i
j = j + 1
Loop
For j = 1 To (1 + (num - i))
a = " " & a
Next j
Print a
Next i
Oct 11 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: frozenee | last post by:
I've noticed that the listings in help don't take you to correct topic. anyone else have this problem? Is there a fix?
4
by: Jeffrey Barrett | last post by:
Can someone tell me why I'm having this problem: When I select drink 5 and deposit too little money, there's a problem with the 'difference' variable. Try to deposit $.80 instead of the full $.85...
2
by: clinttoris | last post by:
Hello, If someone could help me it would be appreciated as I am not having much luck. I'm struggling with my asp code and have some questions relating to asp and oracle database. First...
43
by: SLH | last post by:
hi people. im trying to validate input received via a text area on an ASP page before writing it to a database. i cant use client side javascript due to policy, so it all has to happen on the...
21
by: asif929 | last post by:
I need immediate help in writing a function program. I have to write a program in functions and use array to store them. I am not familiar with functions and i tried to create it but i fails to...
5
by: talktozee | last post by:
Hello, everyone! Here's are the basics: 1. The query looks at all positions that are active and haven't been filled. 2. It then has to look at every single position and determine three...
1
by: darrel | last post by:
Hi vb master i need help on this here my code: If Combo1(0) = rs.Fields("TimeStart") And Combo4(0) = rs.Fields("TimeEnd") And Combo2(0) = rs.Fields("ROOM") And Combo3(0) = rs.Fields("DAYS")...
1
by: vijayarl | last post by:
Hi Everyone, i have the written this logic : basically a file operation open (CONFIGFILE, "$config_file") or die; while (<CONFIGFILE>) { chomp;
11
by: KashMarsh | last post by:
I added the 2 str's below. How do I add them into the SELECT INTO while still keeping the looping syntax? The field names in the table (tShipDetails) are Qty and StockID. Any help is appreciated....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.