Jump to content

UBound($aArray)-1 => Array variable has incorrect number of subscripts or subscript dimension range exceeded


Go to solution Solved by musahi0128,

Recommended Posts

Posted (edited)

Hi guys,

Supposed i have this array

image.png.e836e00ebd7a969d54412f7e280d18dd.png

I need to call a function after row 0, row 1, and row 4. Simply put I need to call a function if the data on col 5 next row is different from current data.

My current code is as follow. It works for row 0 and row 1 but it fail for row 4 with error "Array variable has incorrect number of subscripts or subscript dimension range exceeded"

For $a = 0 To UBound($aQuery) -1
  If BitOR($a = UBound($aQuery)-1, $aQuery[$a][5] <> $aQuery[$a + 1][5]) Then
    ; call a function here
  EndIf
Next

I know the error is to be expected, but I can't think of other way to approach my needs.

Any idea how to approach it?

Thanks!

Edited by musahi0128
Correction on how to explain my needs
  • Solution
Posted
1 hour ago, ad777 said:

@musahi0128

this should works without error:

For $a = 0 To UBound($aQuery) -2
  If BitOR($a = UBound($aQuery)-1, $aQuery[$a][5] <> $aQuery[$a + 1][5]) Then
    ; call a function here
  EndIf
Next

 

Yes it's eliminate the error but also skip the last step. 
But then this is giving me the inspiration I needed,
Just add one empty row to the array and bam, it works!
Thanks dude, love you hahaha

Posted
1 minute ago, Nine said:

It is like applying a band-aid over a headache.   Did you even try my proposal ?  

I don't bro, my brain isn't working right right now wkwkwk

After adding an empty row to the array and changing to UBound()-2 it just works for me.

And your proposal seems to count the value backward, is that right ?

Posted
Just now, musahi0128 said:

Well, i still need it to run forward

That is a well explained argument.  And probably has nothing with reality.  Let me say, that paradigm is a dangerous tangent against intelligence.  Good luck anyway.

Posted
1 minute ago, Nine said:

That is a well explained argument.  And probably has nothing with reality.  Let me say, that paradigm is a dangerous tangent against intelligence.  Good luck anyway.

I don't get what you are saying but thanks !

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...