G
Guest
I receive the above error message when trying to execute the below code. The
For...Next loop increment variable, I, is highlighted. What is wrong with the
code. Is it a declaration error?
--
Software Cub.
The Code is:
Dim intNumberOfForkLiftTests As Integer
Dim intIncrementTopRange As Integer
Dim I As Integer
Dim strForkLiftPersonTested As String
If SpecialInstructions > 0 Then
SpecialInstructions = SpecialInstructions & Chr(13) & Chr(10) &
"Forklift Testing For:" & _
Chr(13) & Chr(10) & " "
Else
SpecialInstructions = "Forklift Testing For:" & Chr(13) & Chr(10) &
" "
End If
intNumberOfForkLiftTests = InputBox("Enter the Number of Fork Lift Tests
Administered.")
intIncrementTopRange = intNumberOfForkLiftTests
For I = 1 To intIncrementTopRange
Dim strName(I) As String
strForkLiftPersonTested = InputBox("Enter the Name of the Fork Lift
Person Tested.")
strName(I) = strForkLiftPersonTested
If I = 1 And I = intIncrementTopRange Then
SpecialInstructions = SpecialInstructions & strName(I) & "."
ElseIf I = 1 And (I + 1) = intIncrementTopRange Then
SpecialInstructions = SpecialInstructions & strName(I) & ", And "
ElseIf I = 1 And (I + 1) < intIncrementTopRange Then
SpecialInstructions = SpecialInstructions & strName(I) & ", "
ElseIf I > 1 Then
If I Mod 2 = 0 And I = intIncrementTopRange Then
SpecialInstructions = SpecialInstructions & strName(I) & "."
ElseIf I Mod 2 = 0 And (I + 1) = intIncrementTopRange Then
SpecialInstructions = SpecialInstructions & strName(I) & ",
And" & Chr(13) & Chr(10) & " "
ElseIf I Mod 2 = 0 And (I + 1) < intIncrementTopRange Then
SpecialInstructions = SpecialInstructions & strName(I) & ","
& Chr(13) & Chr(10) & " "
ElseIf I Mod 2 > O And I = intIncrementTopRange Then
SpecialInstructions = SpecialInstructions & strName(I) & "."
ElseIf I Mod 2 > O And (I + 1) = intIncrementTopRange Then
SpecialInstructions = SpecialInstructions & strName(I) & ",
And "
ElseIf I Mod 2 > O And (I + 1) < intIncrementTopRange Then
SpecialInstructions = SpecialInstructions & strName(I) & ", "
End If
End If
Next I
SpecialInstructions = SpecialInstructions & Chr(13) & Chr(10) &
"Dispensed on " & DateDispensed
Refresh
For...Next loop increment variable, I, is highlighted. What is wrong with the
code. Is it a declaration error?
--
Software Cub.
The Code is:
Dim intNumberOfForkLiftTests As Integer
Dim intIncrementTopRange As Integer
Dim I As Integer
Dim strForkLiftPersonTested As String
If SpecialInstructions > 0 Then
SpecialInstructions = SpecialInstructions & Chr(13) & Chr(10) &
"Forklift Testing For:" & _
Chr(13) & Chr(10) & " "
Else
SpecialInstructions = "Forklift Testing For:" & Chr(13) & Chr(10) &
" "
End If
intNumberOfForkLiftTests = InputBox("Enter the Number of Fork Lift Tests
Administered.")
intIncrementTopRange = intNumberOfForkLiftTests
For I = 1 To intIncrementTopRange
Dim strName(I) As String
strForkLiftPersonTested = InputBox("Enter the Name of the Fork Lift
Person Tested.")
strName(I) = strForkLiftPersonTested
If I = 1 And I = intIncrementTopRange Then
SpecialInstructions = SpecialInstructions & strName(I) & "."
ElseIf I = 1 And (I + 1) = intIncrementTopRange Then
SpecialInstructions = SpecialInstructions & strName(I) & ", And "
ElseIf I = 1 And (I + 1) < intIncrementTopRange Then
SpecialInstructions = SpecialInstructions & strName(I) & ", "
ElseIf I > 1 Then
If I Mod 2 = 0 And I = intIncrementTopRange Then
SpecialInstructions = SpecialInstructions & strName(I) & "."
ElseIf I Mod 2 = 0 And (I + 1) = intIncrementTopRange Then
SpecialInstructions = SpecialInstructions & strName(I) & ",
And" & Chr(13) & Chr(10) & " "
ElseIf I Mod 2 = 0 And (I + 1) < intIncrementTopRange Then
SpecialInstructions = SpecialInstructions & strName(I) & ","
& Chr(13) & Chr(10) & " "
ElseIf I Mod 2 > O And I = intIncrementTopRange Then
SpecialInstructions = SpecialInstructions & strName(I) & "."
ElseIf I Mod 2 > O And (I + 1) = intIncrementTopRange Then
SpecialInstructions = SpecialInstructions & strName(I) & ",
And "
ElseIf I Mod 2 > O And (I + 1) < intIncrementTopRange Then
SpecialInstructions = SpecialInstructions & strName(I) & ", "
End If
End If
Next I
SpecialInstructions = SpecialInstructions & Chr(13) & Chr(10) &
"Dispensed on " & DateDispensed
Refresh