-
Nov 14th, 2017, 04:43 PM
#1
Thread Starter
New Member
Hello having a run time error
Hi I have an error saying Run-Time error 9 subscript out of range.
vb6.0 highlights this line.
Code:
If Player(Index).Version <> GetVar(App.Path & "\data\config.ini", "CONFIG", "VERSION") Then
What dose it mean when it says, Run-Time error 9 subscript out of range.
-
Nov 14th, 2017, 04:47 PM
#2
Re: Hello having a run time error
Welcome to the forums
The error is probably because the value Index is not within the LBound or UBound of the Player() array
-
Nov 14th, 2017, 05:05 PM
#3
Re: Hello having a run time error
Interesting. I just sent someone an email about a similar problem. Here's a snippet from that email:
Basically, in VB, you can grab memory for an array. For instance, we might do something like...
Dim SomeArray(1 to 5) As Double
Basically, this says to create space for five numbers. We could set them as following...
SomeArray(1) = 123
SomeArray(2) = 234
SomeArray(3) = 345
SomeArray(4) = 456
SomeArray(5) = 567
However, what's going to happen if we go...
SomeArray(6) = 678
That's when we get an Error 9. We've attempted to use some memory that we haven't requested/allocated. VB will stop you from doing this, with Error 9. You get the Error 9 if you're trying to write-to or read-from some non-allocated memory.
Blueboxos, in your case, the GetVar(...) piece is almost certainly a request to dig something out of an INI file. However, without the code, that isn't 100% certain. But, since there are multiple arguments, some Strings, that's almost certainly not producing the Error 9. And, if something down in that function were out-of-bounds for an array, it would have shown you the line down in that function.
Therefore, as LaVolpe pointed out, we should be focusing on Player(...). Since you've used the dot-reference with it (Player(...).Version), it must be either an array of class objects, or an array of user-defined-types (UDTs) (or, maybe a control array of some control with a Version property?).
You are definitely over-running an array. However, an array of what is still an outstanding question. If you could tell us a bit more about what Player(...) is, we could probably help more.
Good Luck,
Elroy
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
-
Nov 15th, 2017, 06:29 AM
#4
Re: Hello having a run time error
Originally Posted by blueboxos
Hi I have an error saying Run-Time error 9 subscript out of range.
vb6.0 highlights this line.
Code:
If Player(Index).Version <> GetVar(App.Path & "\data\config.ini", "CONFIG", "VERSION") Then
What dose it mean when it says, Run-Time error 9 subscript out of range.
I notice you are using Index in 3 cases
- IsPlaying(Index)
- Player(Index)
- GetPlayerName(Index)
Questions
- Are IsPlaying() and GetPlayerName() arrays or functions?
- What is the value of Index at the highlighted line?
To answer the second one, move your mouse over the word "Index" and the value should show
Spoo
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|