bythesea
03-26-2003, 07:16 AM
can someone advise me on what's wrong with the following sample codes?
thnx in advance.
private sub MethodA()
while
..........call MethodB(iterator, wksheet)
wend
end sub
private Sub MethodB(a As CListIterator, ws As Excel.worksheet)
Dim flag As Boolean
flag = True
While a.HasMoreItems And flag
If ws.Cells(2, i) <> "" Then <-------------highlighted error
If a.CurrStep = ws.Cells(2, i) Then
ws.Cells(4, i) = a.CurrQuantity
i = 3
a.MoveOn
Else
i = i + 1
End If
Else
flag = False
End If
Wend
End Sub
im very sure the while loop in MethodB was able to execute smoothly. the
problem comes after several iterations when the following errr message appears
as indicated in the highlighted line above:
"Run-time error '91'
Object variable or With Block variable not set"
if i do not have any problem for the first 20-40 iterations, why does the
error occur now?
i have been stuck for a few hours and would appreciate any advice or guidance.
thanks
note: MethodB is the exact set of codes im using in my program
thnx in advance.
private sub MethodA()
while
..........call MethodB(iterator, wksheet)
wend
end sub
private Sub MethodB(a As CListIterator, ws As Excel.worksheet)
Dim flag As Boolean
flag = True
While a.HasMoreItems And flag
If ws.Cells(2, i) <> "" Then <-------------highlighted error
If a.CurrStep = ws.Cells(2, i) Then
ws.Cells(4, i) = a.CurrQuantity
i = 3
a.MoveOn
Else
i = i + 1
End If
Else
flag = False
End If
Wend
End Sub
im very sure the while loop in MethodB was able to execute smoothly. the
problem comes after several iterations when the following errr message appears
as indicated in the highlighted line above:
"Run-time error '91'
Object variable or With Block variable not set"
if i do not have any problem for the first 20-40 iterations, why does the
error occur now?
i have been stuck for a few hours and would appreciate any advice or guidance.
thanks
note: MethodB is the exact set of codes im using in my program