Reputation: 254
I am trying to display a message every thousand loops.
This is what i'm going to have to do if not, however my rows go up to 500k or more...
this is what i have tried and works but is very length code write.
if rows_processed = "1000" or "2000" or "3000" 'and so on
then
'do something
end if
Is this even possible?
Upvotes: 0
Views: 2304
Reputation: 6111
Assuming that you're using a For/Next loop, then use the MOD operator to check if the remainder of the currently iterated index and 1000 is 0. If you're using some other type of loop then you'll need to keep a counter variable outside of the loop and increment it inside the loop.
Here is an example:
'Iterate through each value
For index As Integer = 0 To upper_bounds
'Check if the current iteration is a multiple of 1,000
If index MOD 1000 = 0 Then
Console.WriteLine("You've reached the next 1k mark.")
End If
Next
Fiddle: Live Demo
Upvotes: 8