For each....Next syntax

Mondeo

Well-known member
Joined
Nov 10, 2006
Messages
128
Location
Sunny Lancashire
I have this simple for each loop

For each row as datarow in dtResults.rows
Send the email
Next

Now I dont want to send the email everytime based on the value in one of the columns in dtResults, so I need

For each row as datarow in dtResults.rows
If row.item(0).tostring = "" then
Next
End If

Send the email
Next

However this will not compile, it there anyway I can call the next in two different places based on logic?

Thanks
 
Continue

The keyword you are looking for is Continue:

Code:
For Each row As DataRow In dtResults.Rows
    If (row.Item(0).ToString = "") Then Continue For

     Send the email
Next

Good luck :)
 
Last edited by a moderator:
That seems awkward. Why not...

Code:
For Each row as datarow in dtResults.Rows
   If row.item(0).tostring <> "" Then  If its a good row for sending an email
      send the email
   End If
Next
 
Back
Top