• Saves Valuable Time
  • Trusted Accuracy for 12 Years
  • 15-Day Money-Back Guarantee

VB Equivalent to C# For Loops

C# for loops are potentially far more complex than VB For loops.  For this reason many C# for loops need to be converted to VB Do While loops.  Only simple C# for loops having a single initializer and a single iterator are converted to VB For loops.

For example, the second C# for loop must be converted to a VB Do While loop:

C# VB
for (int i = 1; i <= 9; i++)
{
    ...
}

...

for (int i = 9, j = 1; i > 0 && j < 9; i--, j++)
{
    ...
}
For i As Integer = 1 To 9
    ...
Next i

...

Dim i As Integer = 9
Dim j As Integer = 1
Do While i > 0 AndAlso j < 9
    ....
    i -= 1
    j += 1
Loop


Use Instant VB to convert from C# to VB.NET.     

Additional resource: VB.NET and C# Equivalents


Copyright © 1997 – 2017 Tangible Software Solutions Inc.