Click here to Skip to main content
15,889,266 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello I found this code here on code project and it seems to do what I want. However it it written in c# which I'm not familiar with. Any polyglot programmers out there who can convert this to vb.net? I greatly appreciate any help you may give!

C#
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;
    }
}
Posted
Comments
[no name] 8-Aug-13 11:15am    
http://www.developerfusion.com/tools/convert/csharp-to-vb/
joshrduncan2012 8-Aug-13 11:21am    
My idea, as well. If you post as solution, I'll +5 it.

In addition to on-line tools for translation (the one referenced in Solution 1 seems to be one of the best), there is a really good and comprehensive off-line open-source solution.

This is ILSpy:
http://www.ilspy.net/[^],
http://en.wikipedia.org/wiki/.NET_Reflector[^].

First, you need to compile the project and obtain a compiled assembly. It is compiled to CIL:
http://en.wikipedia.org/wiki/Common_Intermediate_Language[^].

You can load assembly into ILSpy and disassemble it. It has the option for output language. Select either C# or VB.NET, and recompile the part of code you need. You are done.

You can decompile the whole assembly at once into a whole full project, complete with all source code and ready to use with Visual Studio.

Good luck,
—SA
 
Share this answer
 
v2
Comments
Manas Bhardwaj 8-Aug-13 13:53pm    
ILSpy looks good. Did not know about it.

Thanks for sharing. +5!
Sergey Alexandrovich Kryukov 8-Aug-13 13:56pm    
You are welcome. Just in brief: ILSpy is not just good, it's blessing, it already saved me in several difficult situations. You can even debug tricky things with it.
—SA
Maciej Los 8-Aug-13 16:19pm    
Very interesting alternative ;)
+5!
Sergey Alexandrovich Kryukov 8-Aug-13 16:28pm    
Try it, it's really impressing code.
Thank you, Maciej.
—SA
Did you really try to look for it? If you do a Google search, the first result would be this:

http://www.developerfusion.com/tools/convert/csharp-to-vb/[^]

And that gives me this result:

VB
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
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 8-Aug-13 13:47pm    
In my limited experience I had so far, this translator is one of the best, my 5.
There is also a very comprehensive off-line method. Please see my answer.
—SA
Maciej Los 8-Aug-13 16:18pm    
+5!
Manas Bhardwaj 8-Aug-13 16:24pm    
thx Maciej!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900