Re: Multivariable Exception
Code:
If failCheck.Checked = True Then
MsgBox("Abs Fail! " & vbNewLine & "Line: " + currentRow.ToString & vbNewLine & " T1: " + testArray(position - 2) + " " + testArray(position - 1) + " " + testArray(position) & vbNewLine & " R1: " + result1Array(cposition) + " " + result1Array(cposition + 1) & vbNewLine & " R2: " + result2Array(cposition) + " " + result2Array(cposition + 1))
End If
pfColumn.Cells(currentRow).Value = "F"
fails += 1
currentRow += 1
GoTo SearchMove 'Need to use to exit 3 fors
End If
ElseIf (result1Array(cposition) <> result2Array(cposition)) Then 'Test for unintended variable changes
If failCheck.Checked = True Then
MsgBox("Result Compare Fail! " & vbNewLine & "Line: " + currentRow.ToString)
End If
pfColumn.Cells(currentRow).Value = "RF"
rfails += 1
currentRow += 1
GoTo SearchMove 'Need to use to exit 3 fors
End If
Next cposition
End If
'Find number in array for rel moves
If IsNumber(testArray, position) And (testArray(position - 1) = "rel") Then
'Iterate array from array position 0 to max
For cposition = 1 To (result1Array.Length - 1)
'Since each command is in format variable|abs/rel|value, see if test data variable matches result variable
If testArray(position - 2).ToLower = result1Array(cposition).ToLower Then
If ((testArray(position - 2).ToLower = "x") Or (testArray(position - 2).ToLower = "y")) Then
testArray(position) *= -1
End If
'Format the rz if the angle is >180
If (testArray(position - 2).ToLower = "rz") Then
testArray(position) = ConvertAngle(testArray(position)).ToString
End If
'Calculate to see if the test passes/fails
If (testArray(position - 1) = "rel") AndAlso (RelComparison2(toDoub(result2Array, cposition + 1), toDoub(result1Array, cposition + 1), toDoub(testArray, position), Convert.ToDouble(tolText.Text))) Then
If debugCheck.Checked = True Then
MsgBox("Rel PASS!" & vbNewLine & "Line: " + currentRow.ToString & vbNewLine & "T1: " + testArray(position - 2) + " " + testArray(position - 1) + " " + testArray(position) & vbNewLine & " R1: " + result1Array(cposition) + " " + result1Array(cposition + 1) & vbNewLine & " R2: " + result2Array(cposition) + " " + result2Array(cposition + 1))
End If
pfColumn.Cells(currentRow).Value = "P"
passes += 1
cposition += 2
Else
If failCheck.Checked = True Then
MsgBox("Rel Fail! " & vbNewLine & "Line: " + currentRow.ToString & vbNewLine & " T1: " + testArray(position - 2) + " " + testArray(position - 1) + " " + testArray(position) & vbNewLine & " R1: " + result1Array(cposition) + " " + result1Array(cposition + 1) & vbNewLine & " R2: " + result2Array(cposition) + " " + result2Array(cposition + 1))
End If
pfColumn.Cells(currentRow).Value = "F"
fails += 1
currentRow += 1
GoTo SearchMove
End If
ElseIf (result1Array(cposition) <> result2Array(cposition)) Then 'Test for unintended variable changes
If failCheck.Checked = True Then
MsgBox("Result Compare Fail! " & vbNewLine & "Line: " + currentRow.ToString)
End If
pfColumn.Cells(currentRow).Value = "RF"
rfails += 1
currentRow += 1
GoTo SearchMove 'Need to use to exit 3 fors
End If
Next cposition
End If
Re: Multivariable Exception
Code:
Else
If failCheck.Checked = True Then
MsgBox("Abs Fail! " & vbNewLine & "Line: " + currentRow.ToString & vbNewLine & " T1: " + testArray(position - 2) + " " + testArray(position - 1) + " " + testArray(position) & vbNewLine & " R1: " + result1Array(cposition) + " " + result1Array(cposition + 1) & vbNewLine & " R2: " + result2Array(cposition) + " " + result2Array(cposition + 1))
End If
pfColumn.Cells(currentRow).Value = "F"
fails += 1
currentRow += 1
GoTo SearchMove 'Need to use to exit 3 fors
End If
ElseIf (result1Array(cposition) <> result2Array(cposition)) Then 'Test for unintended variable changes
If failCheck.Checked = True Then
MsgBox("Result Compare Fail! " & vbNewLine & "Line: " + currentRow.ToString)
End If
pfColumn.Cells(currentRow).Value = "RF"
rfails += 1
currentRow += 1
GoTo SearchMove 'Need to use to exit 3 fors
End If
Next cposition
End If
'Find number in array for rel moves
If IsNumber(testArray, position) And (testArray(position - 1) = "rel") Then
'Iterate array from array position 0 to max
For cposition = 1 To (result1Array.Length - 1)
'Since each command is in format variable|abs/rel|value, see if test data variable matches result variable
If testArray(position - 2).ToLower = result1Array(cposition).ToLower Then
If ((testArray(position - 2).ToLower = "x") Or (testArray(position - 2).ToLower = "y")) Then
testArray(position) *= -1
End If
'Format the rz if the angle is >180
If (testArray(position - 2).ToLower = "rz") Then
testArray(position) = ConvertAngle(testArray(position)).ToString
End If
'Calculate to see if the test passes/fails
If (testArray(position - 1) = "rel") AndAlso (RelComparison2(toDoub(result2Array, cposition + 1), toDoub(result1Array, cposition + 1), toDoub(testArray, position), Convert.ToDouble(tolText.Text))) Then
If debugCheck.Checked = True Then
MsgBox("Rel PASS!" & vbNewLine & "Line: " + currentRow.ToString & vbNewLine & "T1: " + testArray(position - 2) + " " + testArray(position - 1) + " " + testArray(position) & vbNewLine & " R1: " + result1Array(cposition) + " " + result1Array(cposition + 1) & vbNewLine & " R2: " + result2Array(cposition) + " " + result2Array(cposition + 1))
End If
pfColumn.Cells(currentRow).Value = "P"
passes += 1
cposition += 2
Else
If failCheck.Checked = True Then
MsgBox("Rel Fail! " & vbNewLine & "Line: " + currentRow.ToString & vbNewLine & " T1: " + testArray(position - 2) + " " + testArray(position - 1) + " " + testArray(position) & vbNewLine & " R1: " + result1Array(cposition) + " " + result1Array(cposition + 1) & vbNewLine & " R2: " + result2Array(cposition) + " " + result2Array(cposition + 1))
End If
pfColumn.Cells(currentRow).Value = "F"
fails += 1
currentRow += 1
GoTo SearchMove
End If
ElseIf (result1Array(cposition) <> result2Array(cposition)) Then 'Test for unintended variable changes
If failCheck.Checked = True Then
MsgBox("Result Compare Fail! " & vbNewLine & "Line: " + currentRow.ToString)
End If
pfColumn.Cells(currentRow).Value = "RF"
rfails += 1
currentRow += 1
GoTo SearchMove 'Need to use to exit 3 fors
End If
Next cposition
End If
Re: Multivariable Exception
I would recommend losing the goto statements and revamp the code without them as they may very well be causing the problem. Goto statements are virtually unheard of in today's world of VB.
Best to break down large code segment such as what you presented into smaller code segments.
Create a test Excel file where you know the failure points should be of great assistance in drilling down into the logic which is not working as expected.