如下C#代码:
int sum=0;
for(int i=1;i<101;i++)
{
if(i%2!=0)
{
continue;
}
sum+=i;
}
可以考虑用以下VB.NET代码实现:
Dim sum As Integer, i As Integer
For i = 1 To 100
If (i Mod 2 = 0) Then
sum = sum + i
End If
Next
Dim sum As Integer, i As Integer
For i = 1 To 100
If (i Mod 2 <> 0) Then
GoTo continue
End If
sum = sum + i
continue:
Next
另外在VB.NET 2005,已经实现了continue语法
For i As Integer = 0 To 100
If i = 50 skip Console.Writeline statement
If i = 50 Then Continue For
Console.WriteLine(i.ToString)
Next
Do While using Continue statement.
Dim ii As Integer = 1
Do While ii < 100
ii += 1
If i = 50 skip Console.Writeline statement
If ii = 50 Then Continue Do
Console.WriteLine(ii.ToString)
Loop
While using Continue statement.
Dim iii As Integer = 1
While iii < 100
iii += 1
If i = 50 skip Console.Writeline statement
If iii = 50 Then Continue While
Console.WriteLine(iii.ToString)
End While