1 Replies - 583 Views - Last Post: 26 September 2013 - 12:31 AM Rate Topic: -----

#1 Evil Mouse  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 25-September 13

Arrays

Posted 25 September 2013 - 08:23 PM

Hello there! I made a program that is like the game Hangaroo. So far, so good but I keep encountering this 'Run-time error 9'.

I use arrays in my buttons, but I think I messed up the codes.
Private Sub cmdLetter_Click(Index As Integer)
letterClick(0) = "a"
letterClick(1) = "b"
letterClick(2) = "c"
checkLetters
playSound
cmdLetter(Index).Enabled = False
End Sub


And here is the problem. It says that the Subscript is out of range.
For Y = LBound(ans) To UBound(ans)
    If UCase(ans(Y, 1)) = UCase(letterClick(Index)) Then
        ans(Y, 2) = ans(Y, 1)
        loadHint


I tried
UCase(letterClick(3))
but I it doesn't work also.

If it helps, this is what it actually looks like.
]

Is This A Good Question/Topic? 0
  • +

Replies To: Arrays

#2 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 300
  • View blog
  • Posts: 1,770
  • Joined: 26-March 09

Re: Arrays

Posted 26 September 2013 - 12:31 AM

Can you please add a little more context to your post.

appreciate that you've shown the area where the issue is arising, but it would be good to see a little more code around it, especially how the arrays are being declared and populated.

From what you've shown, you've only populated indices 0-2, so if you try to access index(3) it will fail with the error you've posted.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1