![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Hobbyist Programmer
Join Date: Nov 2004
Location: 1691 miles East of L.A.
Posts: 159
Rep Power: 4
![]() |
Private Sub Command1_Click() Dim numlines As Integer Dim i As Integer, j As Integer, k As Integer, b As Integer Text2.Text = vbNullString j = 0: b = 0 numlines = Val(Text1.Text) For i = 1 To numlines b = b + i For k = 1 To b - 1 If j = 0 Then Exit For j = j + 1 Text2.Text = Text2.Text & j & " " Next k j = j + 1 Text2.Text = Text2.Text & j & vbCrLf Next i End Sub '2 textboxes and one command button 'text2 should be large enough to hold the output 'and should have multiline=true along with vert. 'scrollbar unless prefer to print to form 'Likely could have done a better way but it's late. 'output: '1 '2 3 4 '5 6 7 8 9 10 '11 12 13 14 15 16 17 18 19 20 '21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
__________________
-- lostcauz Stepped in what?... Behind whose barn?... I didn't even know they had a cow! |
|
|
|
|
|
#12 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Congratulations. BTW, the number of numbers in each row is are the triangular numbers - 1, 3, 6, 10, 15, 21 etc. The formula for the number of numbers in each row is ½n(n+1), or ½n² + ½n, where n is the row number.
|
|
|
|
|
|
#13 | |
|
Hobbyist Programmer
Join Date: Nov 2004
Location: 1691 miles East of L.A.
Posts: 159
Rep Power: 4
![]() |
Quote:
Private Sub Command2_Click()
Dim i As Integer, j As Integer, k As Integer, b As Integer
For i = 1 To Val(Text1.Text)
b = (i / 2) * (i + 1)
For k = 1 To b
j = j + 1
Text2.Text = Text2.Text & j & " "
Next k
Text2.Text = Text2.Text & vbCrLf
Next i
End SubThat does look nicer. ![]()
__________________
-- lostcauz Stepped in what?... Behind whose barn?... I didn't even know they had a cow! |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|