8 Replies - 834 Views - Last Post: 12 November 2013 - 06:29 PM Rate Topic: -----

#1 benpal95   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 20-October 13

Can anyone gives me some clues on how to start to do this question?

Posted 11 November 2013 - 06:20 AM

Can anyone gives me some clues on how to start to do this question?
Private Sub cmdOne_Click()
Dim rowcol(1 To 6, 1 To 8) As String
For rowcol = 1 To 6 ,1 To 8 ) Step 1
End Sub
 

I stopped on this question by typing so little code only.
I will upload a picture that contain the question.Attached Image
Is This A Good Question/Topic? 0
  • +

Replies To: Can anyone gives me some clues on how to start to do this question?

#2 andrewsw   User is online

  • blow up my boots
  • member icon

Reputation: 6549
  • View blog
  • Posts: 26,557
  • Joined: 12-December 12

Re: Can anyone gives me some clues on how to start to do this question?

Posted 11 November 2013 - 06:34 AM

You would nest for-loops to iterate the 2-dimensional array:

For x = 1 To 6
    For y = 1 To 8

    Next y
Next x

Was This Post Helpful? 1
  • +
  • -

#3 benpal95   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 20-October 13

Re: Can anyone gives me some clues on how to start to do this question?

Posted 11 November 2013 - 08:19 PM

Thanks for the reply. :) I will try on it.

This post has been edited by andrewsw: 12 November 2013 - 04:10 AM
Reason for edit:: Removed previous quote

Was This Post Helpful? 0
  • +
  • -

#4 benpal95   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 20-October 13

Re: Can anyone gives me some clues on how to start to do this question?

Posted 12 November 2013 - 12:16 AM

I have give it a try.
And I have wrote the full code that I think it should be full and complete.
Now, I facing problem on how to show it on TextBox.
Private Sub cmdOne_Click()
Dim symbol(1 To 6, 1 To 8) As String, i As Integer, j As Integer
symbol(1, 1) = "I"
symbol(1, 8) = "N"
symbol(2, 2) = "I"
symbol(2, 4) = "I"
symbol(2, 5) = "I"
symbol(2, 7) = "N"
symbol(3, 3) = "I"
symbol(3, 4) = "N"
symbol(3, 5) = "T"
symbol(3, 6) = "N"
symbol(4, 3) = "T"
symbol(4, 4) = "T"
symbol(4, 5) = "N"
symbol(4, 6) = "I"
symbol(5, 2) = "T"
symbol(5, 4) = "I"
symbol(5, 5) = "I"
symbol(5, 7) = "I"
symbol(6, 1) = "T"
symbol(6, 8) = "I"
     For i = 1 To 6
     For j = 1 To 8
         txtOne.Text = symbol(i, j) & vbNewLine
     Next j
     Next i
End Sub

Attached image(s)

  • Attached Image

This post has been edited by andrewsw: 12 November 2013 - 04:11 AM
Reason for edit:: Removed previous quote

Was This Post Helpful? 0
  • +
  • -

#5 benpal95   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 20-October 13

Re: Can anyone gives me some clues on how to start to do this question?

Posted 12 November 2013 - 01:00 AM

I have changed some of my code.
Private Sub cmdOne_Click()
Dim symbol(1 To 8, 1 To 6) As String, i As Integer, j As Integer
symbol(1, 1) = "I"
symbol(1, 6) = "T"
symbol(2, 2) = "I"
symbol(2, 4) = "T"
symbol(3, 3) = "I"
symbol(3, 4) = "T"
symbol(4, 2) = "I"
symbol(4, 3) = "N"
symbol(4, 4) = "T"
symbol(4, 5) = "I"
symbol(5, 2) = "I"
symbol(5, 3) = "T"
symbol(5, 4) = "N"
symbol(5, 5) = "I"
symbol(6, 3) = "N"
symbol(6, 4) = "I"
symbol(7, 2) = "N"
symbol(7, 4) = "I"
symbol(8, 1) = "N"
symbol(8, 6) = "I"
     For i = 1 To 8
     For j = 1 To 6
          txtOne.Text = txtOne.Text & symbol(i, j) & vbNewLine
     Next j
          txtOne.Text = txtOne.Text & symbol(i, j) & vbNewLine
     Next i
End Sub

Attached image(s)

  • Attached Image

This post has been edited by andrewsw: 12 November 2013 - 04:12 AM
Reason for edit:: Removed previous quote

Was This Post Helpful? 0
  • +
  • -

#6 andrewsw   User is online

  • blow up my boots
  • member icon

Reputation: 6549
  • View blog
  • Posts: 26,557
  • Joined: 12-December 12

Re: Can anyone gives me some clues on how to start to do this question?

Posted 12 November 2013 - 04:18 AM

There is no need to keep quoting the previous post, it makes the topic very long and hard to read. There is a larger Reply button a little further down the page.

So what line does it take you to when you press Debug? When you do this you can point at the variables i and j and it will tell you what values these currently hold.

In the meantime this:

txtOne.Text = symbol(i, j) & vbNewLine

will overwrite the Text each time. You need to append to, to concatenate, this text:

txtOne.Text = txtOne.Text & symbol(i, j) & vbNewLine

Was This Post Helpful? 1
  • +
  • -

#7 benpal95   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 20-October 13

Re: Can anyone gives me some clues on how to start to do this question?

Posted 12 November 2013 - 07:01 AM

Erm... You mentioned the things just like the picture below?

Attached image(s)

  • Attached Image

Was This Post Helpful? 0
  • +
  • -

#8 maj3091   User is offline

  • D.I.C Lover
  • member icon

Reputation: 330
  • View blog
  • Posts: 1,998
  • Joined: 26-March 09

Re: Can anyone gives me some clues on how to start to do this question?

Posted 12 November 2013 - 03:05 PM

The image you have posted (post #7) is not appending on the line in the "j" loop,so it will just write a single output each time in that loop.

This image seems to contradict some of the code you posted above (post #5) which is appending in each case.

Did you check the values of I and J in the highlighted line (you'll find that one them is outside the range). ;)

Also, the line that writes out each line (J loop) doesn't need a newline on each output, otherwise you will just be drawing down the screen. You only need to add a newline when you need to go to the next line (after completing each iteration of the J loop).

You will still find that your formatting will be out, but let's see if you can figure that one out yourself first.
Was This Post Helpful? 1
  • +
  • -

#9 benpal95   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 20-October 13

Re: Can anyone gives me some clues on how to start to do this question?

Posted 12 November 2013 - 06:29 PM

View Postmaj3091, on 13 November 2013 - 06:05 AM, said:

The image you have posted (post #7) is not appending on the line in the "j" loop,so it will just write a single output each time in that loop.

This image seems to contradict some of the code you posted above (post #5) which is appending in each case.

Did you check the values of I and J in the highlighted line (you'll find that one them is outside the range). ;)/>

Also, the line that writes out each line (J loop) doesn't need a newline on each output, otherwise you will just be drawing down the screen. You only need to add a newline when you need to go to the next line (after completing each iteration of the J loop).

You will still find that your formatting will be out, but let's see if you can figure that one out yourself first.


Thanks for all the solution you provided. :) I have managed to solve the problems.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1