In my Basic code sometimes when I use round brackets (parentheses) for array access (eg. MyArray(2)) I will get an error saying MyArray is not a function. The only work around I’ve found is to use the Java format square brackets (eg. MyArray) - is this normal?
You’ll need to have one in the code module itself. If it is in a different code module or form, the Translator will not know that you mean it to be an array. It’s OK to have multiple DIM statements for the same array in different modules - nothing will get messed up.
I have the following code where GameBetsArray is defined in the same function it is used, but I still get an error saying GameBetsArray is not a function - if I use square brackets (GameBetsArray[i] and GameBetsArray[i]) I don’t get the error. The UBound(GameBetsArray) never seems to have a problem.
Dim GameBetsArray = Array() For i = 0 To results.rows.length-1 Push(GameBetsArray,Array(results.rows.item(i)["game"],results.rows.item(i)["defaultbet"])) Next If GameSelect.ListCount > 1 Then Game1Value.value = 0 For i = 0 To UBound(GameBetsArray) If GameBetsArray(i,0) = GameSelect.List(1) Then Game1Value.value = GameBetsArray(i,1) Exit For End If Next End If
What happens if you do this:
NS BASIC Corporation
That solves the bracket problem, but then the first Push into the array puts the elements in (1,0) and (1,1) and not (0,0) and (0,1) (GameBetsArray(0,0) is undefined)
What is your push statement exactly?
(Tip: when entering code using the web interface of this board, use the </> icon to format the code nicely)
It’s the Push statement shown in the code at the top of this discussion
I see what you mean now - if I use both of the following statements I get the results I want:
GameBetsArray = Array()