Zuccj
07-07-2017, 05:13 AM
I have two arrays of the same size, and trying to bit-wise OR them into another array of the same size. When the program gets to the line of code that does the or I'm getting run time error 9: Subscript out of range.
Sub zap_chip()
Dim zap_mask(0 To 15) As Long
Dim verify_low(0 To 15) As Long
Dim verify_high(0 To 15) As Long
Dim error_mask(0 To 15) As Long
Dim zap_req As Boolean
ulMHL200Error = MHL200_GetRegister(ulMHL200Handle, &H0, verify_low(0))
.
.
.
Array getting populated, just showing one to save space
Dim k As Integer
For k = 0 To 15 Step 1
error_mask(k) = verify_low(k)
verify_high(k) = verify_low(k)
Next k
MsgBox "Testing Low Verification" & vbNewLine & "Press Any Key To Continue."
ulMHL200Error = MHL200_ZapVerify(ulMHL200Handle, 0, verify_low, error_mask)
If (ulMHL200Error = eMHL200_OK) Then
MsgBox "Low Verification Complete" & vbNewLine & "Press Any Key To Continue To High Verification"
ulMHL200Error = MHL200_ZapVerify(ulMHL200Handle, 1, verify_high, error_mask)
End If
Dim i As Integer
If (ulMHL200Error = eMHL200_ZAP_IMPOSSIBLE) Then
MsgBox "Zapping Impossible. An Already zapped bit can not be 0."
For i = 0 To 15 Step 1
If (error_mask(i) <> 0) Then
MsgBox "Error Mask Register 0x" & i & vbNewLine & ":0x" & error_mask(i)
End If
Next i
Exit Sub
ElseIf (ulMHL200Error <> eMHL200_OK) Then
MsgBox "An Error Occured During Verification." & vbNewLine & "Error Code:" & ulMHL200Error
Exit Sub
ElseIf (ulMHL200Error = eMHL200_OK) Then
MsgBox "Verification Complete" & vbNewLine & "Press Any Key to Continue Zapping"
End If
zap_req = False
For i = LBound(zap_mask) To UBound(zap_mask)
MsgBox "test 1"
zap_mask(i) = verify_low(i) Or verify_high(i)
If (zap_mask(i) <> 0) Then
MsgBox "test 2"
zap_req = True
End If
Next i
If (zap_req = True) Then
ulMHL200Error = MHL200_ZapEx(ulMHL200Handle, zap_mask)
If (ulMHL200Error = eMHL200_OK) Then
MsgBox "Zapping Complete"
Else: MsgBox "An Error occured during Zapping"
End If
Else: MsgBox "All Bits Are Zapped"
End If
End Sub
The line in red is what is giving me the error. Test 1 is displayed only once, so the programing is failing the second it hits that line. Not sure what can be causing it, as from what I saw online it mostly means something is either out of range, or named wrong which I don't see in this case. The section in the middle is just error checking, and should have no affect on the arrays.
Edit: just realized the line didn't get highlighted that is throwing the error.
>>>zap_mask(i) = verify_low(i) Or verify_high(i)
That is the line that is throwing the subscript error
Sub zap_chip()
Dim zap_mask(0 To 15) As Long
Dim verify_low(0 To 15) As Long
Dim verify_high(0 To 15) As Long
Dim error_mask(0 To 15) As Long
Dim zap_req As Boolean
ulMHL200Error = MHL200_GetRegister(ulMHL200Handle, &H0, verify_low(0))
.
.
.
Array getting populated, just showing one to save space
Dim k As Integer
For k = 0 To 15 Step 1
error_mask(k) = verify_low(k)
verify_high(k) = verify_low(k)
Next k
MsgBox "Testing Low Verification" & vbNewLine & "Press Any Key To Continue."
ulMHL200Error = MHL200_ZapVerify(ulMHL200Handle, 0, verify_low, error_mask)
If (ulMHL200Error = eMHL200_OK) Then
MsgBox "Low Verification Complete" & vbNewLine & "Press Any Key To Continue To High Verification"
ulMHL200Error = MHL200_ZapVerify(ulMHL200Handle, 1, verify_high, error_mask)
End If
Dim i As Integer
If (ulMHL200Error = eMHL200_ZAP_IMPOSSIBLE) Then
MsgBox "Zapping Impossible. An Already zapped bit can not be 0."
For i = 0 To 15 Step 1
If (error_mask(i) <> 0) Then
MsgBox "Error Mask Register 0x" & i & vbNewLine & ":0x" & error_mask(i)
End If
Next i
Exit Sub
ElseIf (ulMHL200Error <> eMHL200_OK) Then
MsgBox "An Error Occured During Verification." & vbNewLine & "Error Code:" & ulMHL200Error
Exit Sub
ElseIf (ulMHL200Error = eMHL200_OK) Then
MsgBox "Verification Complete" & vbNewLine & "Press Any Key to Continue Zapping"
End If
zap_req = False
For i = LBound(zap_mask) To UBound(zap_mask)
MsgBox "test 1"
zap_mask(i) = verify_low(i) Or verify_high(i)
If (zap_mask(i) <> 0) Then
MsgBox "test 2"
zap_req = True
End If
Next i
If (zap_req = True) Then
ulMHL200Error = MHL200_ZapEx(ulMHL200Handle, zap_mask)
If (ulMHL200Error = eMHL200_OK) Then
MsgBox "Zapping Complete"
Else: MsgBox "An Error occured during Zapping"
End If
Else: MsgBox "All Bits Are Zapped"
End If
End Sub
The line in red is what is giving me the error. Test 1 is displayed only once, so the programing is failing the second it hits that line. Not sure what can be causing it, as from what I saw online it mostly means something is either out of range, or named wrong which I don't see in this case. The section in the middle is just error checking, and should have no affect on the arrays.
Edit: just realized the line didn't get highlighted that is throwing the error.
>>>zap_mask(i) = verify_low(i) Or verify_high(i)
That is the line that is throwing the subscript error