Im trying to compare a variable from the main program into a sub with a set numbers. Im also using a function which will check if the variable is true or false. The sub runs in a loop.
As i run the program excel melts down.
Please Help!!
Below is the sample code:
THIS IS CALLED FROM A DO LOOP
Private Sub InternalTools(ByVal G As Integer)
Dim i As Integer
Dim InternalToolsAre As Integer
i = G
'check for internal tool
On Error GoTo InternalToolsAreNotTrue
For i = 5 To 11 Step 1
If InternalTool(i) = True Then
InternalToolsAre = 1
Exit Sub
End If
Next i
InternalToolsAreNotTrue:
InternalToolsAre = 0
End Sub
AND THE FUNCTION
Function InternalTool(Z) As Boolean
On Error GoTo Nexti
If i = Z Then
InternalTool = True
Exit Function
Else
InternalTool = False
End If
Nexti:
End Function
As i run the program excel melts down.
Please Help!!
Below is the sample code:
THIS IS CALLED FROM A DO LOOP
Private Sub InternalTools(ByVal G As Integer)
Dim i As Integer
Dim InternalToolsAre As Integer
i = G
'check for internal tool
On Error GoTo InternalToolsAreNotTrue
For i = 5 To 11 Step 1
If InternalTool(i) = True Then
InternalToolsAre = 1
Exit Sub
End If
Next i
InternalToolsAreNotTrue:
InternalToolsAre = 0
End Sub
AND THE FUNCTION
Function InternalTool(Z) As Boolean
On Error GoTo Nexti
If i = Z Then
InternalTool = True
Exit Function
Else
InternalTool = False
End If
Nexti:
End Function