How to declare an array within a window


I need to declare an array of type integer that is accessible within a window and private to that window. I created a property within that window and here is what I entered in the property window but I then get an error that says it’s not an array.
Name: NumsToEnter()
Type: Integer
Default: (left blank)
Scope: Private

Could someone please tell me what I’m doing wrong?


What you describe looks perfectly fine. Where are you getting the error?

you get the error? where? when you hit enter trying to define it?
or when you try to assign some to it in code?

You might have a scope issue. Make sure you don’t have another property somewhere with the same name.

Sorry for the long pause - it’s my wife’s birthday and I don’t want a divorce!

The first line that gets the error is:

ReDim NumsToEnter(1 to mconTypingSpeedAsses_NumOfNums)

The error message for this one is: Syntax error

mconTypingSpeedAsses_NumOfNums is a constant declared in the same window:
Constant name: mconTypingSpeedAsses_NumOfNums
Default: 30
Type: Number
Scope: Private

The second line that gets the error is:

NumsToEnter(lintRandomNum) = App.Randomizer(100, 999)

The error message is: This is not an array but you are using it as one.

lintRandomNum is declared in the same method that contains both the above lines of code:

Dim lintRandomNum as Integer

and is assigned the initial value of zero:

lbytCount = 0

All of the above is in the same window as the NumOfNums declaration.

  1. There is no “to” in the redim declaration in Xojo. But we can see that you come from the dark side of VB.

  2. You are missing the inRange function.

Thanks, Beatrix. You’re right about the VB background!

And both your points fixed the problems I was getting.