2009-12-04 54 views
1

什麼是C#在vb.net循環

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); 
    } 
} 
在VB.net

等價?

+1

http://www.developerfusion.com/tools/convert/csharp-to-vb/ 非常適合快速翻譯。 – Jim 2009-12-04 19:39:48

+0

有人真的投票嗎? – 2009-12-06 22:14:15

+0

@Jim感謝您的精彩鏈接。對我真的很有幫助。從c#移動到vb.net .net – 2013-07-08 08:30:29

回答

7
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 
+0

嘿,看,少一行代碼! Magick! ;) – 2013-12-10 02:15:29

4

找到最簡單的方法:編譯該代碼,然後在Reflector中將其設置爲VB的語言來查看它。事實上,你有我們沒有的信息,比如。

反射器不總是給有效的代碼,但它是一個非常好的起點。 (還有其他的工具可用這很可能將做一個更好的工作,但我想你已經有了反射器。)

對於實際的代碼,看到其他的答案:)

+2

教一個人去釣魚,... – 2009-12-04 14:59:49

1
For rowCounter As Integer = 0 To rowCount-1 
    'Do Stuff 
Next 
1
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