tags:

views:

77

answers:

5
+1  Q: 

for loop in vb.net

Hello,

what is the equivalant of

for (int rowCounter = 0;
rowCounter < rowCount; rowCounter++)
{for (int columnCounter = 0;columnCounter < columnCount; columnCounter++)
{string strValue =GridView1.Rows[rowCounter].Cells[columnCounter].Text;
grdTable.AddCell(strValue);
}
}

in VB.net

Thanks in advance

+3  A: 

Simplest way to find out: compile that code, then look at it in Reflector with the language set to VB. As it is, you have information we don't have like what grdTable is.

Reflector doesn't always give valid code, but it's a very good starting point. (There are other tools available which may well do a better job of converting, but I imagine you've already got Reflector.)

For the actual code, see the other answers :)

Jon Skeet
Teach a man to fish, ...
Yannick M.
+6  A: 
For rowCounter As Integer = 0 To rowCount - 1
    For columnCounter As Integer = 0 To columnCount - 1
        Dim strValue As String = GridView1.Rows(rowCounter).Cells(columnCounter).Text
        grdTable.AddCell(strValue)
    Next
Next
Cecil Has a Name
A: 
For rowCounter As Integer = 0 To rowCount-1
    'Do Stuff
Next
Tim
A: 
Dim rowCounter As Integer
For rowCounter = 0 To rowCount
    Dim columnCounter As Integer
    For columnCounter = 0 to columnCount
        Dim strValue as String
        strValue = GridView1.Rows(rowCounter).Cells(columnCounter).Text
        grdTable.AddCell(strValue)
    Next
Next
md5sum
+4  A: 

Here's a very good online converter: http://www.developerfusion.com/tools/convert/csharp-to-vb/

Converts C# to VB.NET and back.

Adam Neal