![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Nov 2004
Posts: 12
Rep Power: 0
![]() |
I need help on coding the following 4 outputs upon press of one of 4 buttons.
XXXXX XXXXX XXXXX 11111 22222 33333 44444 12345 12345 12345 12345 1 x 1 = 1, 1 x 2 = 2, 1 x 3 = 3, 1 x 4 = 5, 1 x 5 = 5, 1 x 6 = 6, 1 x 7 = 7, 1 x 8 = 8, 1 x 9 = 9 2 x 1 = 2, 2 x 2 = 4, 2 x 3 = 6, 2 x 4 = 8, 2 x 5 = 10, 2 x 6 = 12, 2 x 7 = 14, 2 x 8 = 16, 2 x 9 = 18 3 x 1 = 3, 3 x 2 = 6, 3 x 3 = 9, 3 x 4 = 12, 3 x 5 = 15, 3 x 6 = 18, 3 x 7 = 21, 3 x 8 = 24, 3 x 9 = 27 4 x 1 = 4, 4 x 2 = 8, 4 x 3 = 12, 4 x 4 = 16, 4 x 5 = 20, 4 x 6 = 24, 4 x 7 = 28, 4 x 8 = 32, 4 x 9 = 36 5 x 1 = 5, 5 x 2 = 10, 5 x 3 = 15, 5 x 4 = 20, 5 x 5 = 25, 5 x 6 = 30, 5 x 7 = 35, 5 x 8 = 40, 5 x 9 = 45 …………………………………………………up to 9 x 9 = 81 Any help is appreciated, thanks. |
|
|
|
|
|
#2 |
|
Programming Guru
![]() ![]() |
Have you tryed any code out yet? We like to see people's code with they're posts.
Mainly because we've had people come on the forum expecting us to do they're homework.
__________________
Profanity is the one language that all programmers understand. Check out my Blog <---updated Nov 30 2007! |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Nov 2004
Posts: 12
Rep Power: 0
![]() |
Well Im still a beginner and trying to grasp FOR loops. Its just that I have no clue how to make the FOR loop work to display my first output for example.
Dim output As String
Dim X As Integer
Dim Y As Integer
For X = 5 To 15 Step 5
For Y = 3 To X
output = output + "X"
Next Y
output = output + ""
Next X
lblLoop.Text = outputI know I'm doing something wrong. Maybe with an example or a hint will help me to figure this out. Thanks. |
|
|
|
|
|
#4 |
|
Expert Programmer
|
Remember that your out loop will control values changing along the Y axis (coloumns) and your inner loop will control variables changing along the X axis (rows).
For example you could produce this output: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ... with this code (in C++) int i = 0;
//first loop (outer) controls Y axis
for( int j = 0; j < 4; j++ )
{
//inner loop controls X axis
for( int n = 0; n < 5; n++ )
{
cout << i;
i += 1;
}
//print a newline to bring us to the next line
count << "\n";
}Sorry I have not done pascal in so long I figure it owuld be easiest for me to do this in C, grammatical components of both languages are similar enough that you should be capable of interpretting it, or maybe someone else will convert it to Pascal ![]()
__________________
Clifford Matthew Roche <geek@cliffordroche.com> Web Hosting: http://www.crd-hosting.com Consulting: http://www.crdev-consulting.com |
|
|
|
|
|
#5 |
|
PFO Founder
![]() ![]() |
This is a Visual Basic problem right if so here is what i got for the XXXXX one
Dim i As Integer
Dim j As Integer
Dim output As String
For i = 1 To 3 Step 1
For j = 1 To 5 Step 1
output = output & "X"
Next
output = output & Chr(10)
Next
Me.Label1.Caption = output
__________________
BIG K aka Kyle Programming Forums Kyle K Online Please do not PM or email me programming questions. Post them in the forums instead. |
|
|
|
|
|
#6 |
|
Newbie
Join Date: Nov 2004
Posts: 12
Rep Power: 0
![]() |
Yes it is a visual basic problem and thanks for the help both of you. Now onto the mystery which is the second problem. Will it take a similar FOR loop for the second one or would there have to be another variable to declare for it to work? Kind of stuck on that part.
|
|
|
|
|
|
#7 |
|
PFO Founder
![]() ![]() |
it will be the same type of loop its just a matter of declaring another variable that will change according to what numbers you need to print out
good luck
__________________
BIG K aka Kyle Programming Forums Kyle K Online Please do not PM or email me programming questions. Post them in the forums instead. |
|
|
|
|
|
#8 |
|
Programming Guru
![]() ![]() |
Here's what i would do for the second one:
dim x as integer
dim y as integer
dim num as integer
dim output as string
num = 1
output = ""
for y = 0 to 3 step 1
for x = 0 to 4 step 1
output = output & num
next x
output = output & vbCrLf
num = num + 1
next y
Me.label.caption = outputfor the next one:
dim x as integer
dim y as integer
dim output as string
output = ""
for y = 0 to 3 step 1
for x = 1 to 5 step 1
output = output & x
next x
output = output & vbCrLf
next y
Me.label.caption = outputi am sure that you get the idea now about how thing are working.
__________________
Profanity is the one language that all programmers understand. Check out my Blog <---updated Nov 30 2007! |
|
|
|
|
|
#9 |
|
Newbie
Join Date: Nov 2004
Posts: 12
Rep Power: 0
![]() |
Ok guys, on the fourth problem, I figured it out but the output is displaying the numbers unevenly. For example I wanted all the 1x# in one row and then enter down and the 2x# will start on the row below it. But some of the 2x# is in the 1x# row. How would I go about to put all the number into seperate rows? Heres my code:
Dim x As Integer
Dim y As Integer
Dim output As String
output = ""
For y = 9 To 1 Step -1
For x = 9 To 1 Step -1
output = x * y
lblMultiply.Text = y & "x" & x & "=" & output & ", " & lblMultiply.Text
Next x
output = output & vbCrLf
Next yThanks alot. |
|
|
|
|
|
#10 |
|
PFO Founder
![]() ![]() |
you could try adding the chr(10) to the output like i did above the chr(10) is the return charector. give that a go and see what happens
![]()
__________________
BIG K aka Kyle Programming Forums Kyle K Online Please do not PM or email me programming questions. Post them in the forums instead. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|