我该如何将这个c代码转换为vb.net

本文关键字:转换 代码 vb net | 更新日期: 2023-09-27 18:27:05

你好,我在网上找到了这段代码,它似乎可以随心所欲。然而,它是用c#编写的,我对此并不熟悉。有任何精通多种语言的程序员可以将其转换为vb.net吗?我非常感谢你的帮助!

foreach (DataGridViewColumn clm in grdView.Columns)
{
Bool FoundData = false;
foreach (DataGridViewRow row in grdView.Rows)
{
     if (row.Cells[clm.Index].Value.ToString() != string.Empty)
     {
         FoundData = true;
         break;
     }
}
if (!FoundData)
{
     grdView.Columns[clm.Index].Visible = false;
}
}

我该如何将这个c代码转换为vb.net

试试这个:

For Each clm As DataGridViewColumn In grdView.Columns
    Dim FoundData As Boolean = False
    For Each row As DataGridViewRow In grdView.Rows
        If row.Cells(clm.Index).Value.ToString() <> String.Empty Then
            FoundData = True
            Exit For
        End If
    Next
    If Not FoundData Then
        grdView.Columns(clm.Index).Visible = False
    End If
Next

您可以使用任何在线转换工具。http://www.carlosag.net/tools/codetranslator/

 For Each clm As DataGridViewColumn In grdView.Columns
   Dim FoundData As Bool = false
 For Each row As DataGridViewRow In grdView.Rows
    If (row.Cells(clm.Index).Value.ToString <> string.Empty) Then
        FoundData = true
        Exit For
    End If
 Next
 If Not FoundData Then
    grdView.Columns(clm.Index).Visible = false
 End If
 Next

试试这个工具。您可能会发现它对未来的转换很有帮助:http://www.developerfusion.com/tools/convert/vb-to-csharp/