0

I have to check an Excel file with more than 5000 rows. In certain cases, though, I have nothing to do. How can express it in VB.NET?

For r = 196 To 5549  
    If r = 1233 And r = 1745 Then
        'Do nothing
    End If
Next

This is an example that what I'd like. How can I do?

Sebastian Brosch
  • 42,106
  • 15
  • 72
  • 87
Matteo
  • 316
  • 1
  • 7
  • 21

1 Answers1

1

You can skip the current For step by using Continue For:

For r = 196 To 5549  
    If r = 1233 Or r = 1745 Then
        'Do nothing
        Continue For
    End If

    'Do something
Next

In case your list of numbers is growing you an also use the following code:

For r = 196 To 5549  
    If Array.IndexOf({1233, 1745}, r) > -1 Then
        'Do nothing
        Continue For
    End If

    'Do something
Next

Hint: There seems something wrong with your condition. r can't be 1233 and 1745. It can be only 1233 or 1745.

Sebastian Brosch
  • 42,106
  • 15
  • 72
  • 87