Strange array Index issue found

Dim vIndex As Integer
Dim vTemp as String

For vIndex = 0 to 100
vTemp = gData.mData( vIndex )
code…
gData.mData( index ) = vTemp
Next vIndex

This code ran with no errors on a windows machine using 2017R3

I have no local or global variable named {index} just local {vIndex} in a method.
gData.mData( index ) = vTemp loaded vTemp into array element 0 every time.
It did compile and run in DEBUGER with no error. What gives…

Without knowing exactly what the error is it’s a little hard to help. Did it throw an exception or is that it shouldn’t put data into array element 0?

When you hover the mouse over index, what displays below?

Your code as shown above:

For vIndex = 0 to 100 vTemp = gData.mData( vIndex ) code... gData.mData( index ) = vTemp <---- Shouldn't this be vIndex and not index? Next vIndex
The line I have pointed to is using a different index from the loop index of vIndex.

Where do the code resides ? It “may” be a parameter of the location the code resides…

Good catch @Simon Berridge.

@william carras , please use the Code tags when posting code to make it easier for us to help.

@Simon Berridge , that was his point. He made that typo, but it compiled anyway, leaving him confused as to why it didn’t throw a compile error. He doesn’t think there is any property in his project with that name, so the compiler should have complained.

@william carras , did you inadvertently make this control a control set? Just guessing here.

Thanks for all the answers. it was code in a simple method that did not give an error that variable ( index ) was not declared.
It took some hard looking to figure out what was going on. I did a search thru out the whole program for the variable index . nothing found. but it compiled and ran in the debugger. And if someone can tell me how to use code tags… i’ll use them Thanks again…

So you found the problem? What was it? I’m guessing that index was a parameter of the method or event.

Code Tags are easy, two ways to to it

  • click the code icon in the upper right corner (docoument icon with the <>) and enter you code between those tags
  • just type the tags to start and to end (however, use SQUARE brackets [] not <>)

[quote=387520:@Dave S]Code Tags are easy, two ways to to it

  • click the code icon in the upper right corner (docoument icon with the <>) and enter you code between those tags
  • just type the tags to start and to end (however, use SQUARE brackets [] not <>)[/quote]
    Or type your code first without the tags, then select it and click the icon.