AnsweredAssumed Answered

Comparing Array items - VBA

Question asked by Raymond Yau on Aug 17, 2017
Latest reply on Aug 17, 2017 by Raymond Yau

Hi,

 

This is more of a VBA rather than a Solidworks question. I'm trying to compare the first item in an array with the second item in the array as follows:

 

        i = 0
        
        For Each i In LengthsArr
        If LengthsArr(i) > LengthsArr(i + 1) Then
        llong = llong + QuanArr(i)
        Else
        Short = Short + QuanArr(i)
        
        End If
        
        Next i

 

It doesn't seem to work, line 4 throws up an error:

 

"Run-time error: 9: Subscript out of range"

 

Anybody know why I am getting this?

Outcomes