Looks like this tool helps you to convert any VB.NET class into C#. There's an online and offline version, which are both free!
http://www.wimontheweb.com/ca_main.aspx
Printable View
Looks like this tool helps you to convert any VB.NET class into C#. There's an online and offline version, which are both free!
http://www.wimontheweb.com/ca_main.aspx
Tried it on one of the most common things:
MsgBox("Hello World")
and it doesn't work.
Well duh. msgbox is a VB6 compatability thing. So they probably ignored it. MessageBox.Show is the "proper" .NET way.
:afrog:
but most of the books stated that Msgbox(text) is command for message box
I guess that might be, but that's considered, well, almost depricated, or worse, inside of the VisualBasic namespace. MessageBox.Show() is "pure" .NET while MsgBox is well, certainly pure .NET, just happens it exists under the Microsoft and not System namespace.Quote:
Originally posted by morpheus5
but most of the books stated that Msgbox(text) is command for message box
Have you guys seen most of the vb.net code that is out there? I see more vb people using msgbox than vb people that use MessageBox.Show...
I see more of the Left, Right, CInt, CString, CLong, etc... than the Substring method, or the CType method.
All of those are compaitibility, and are used quite often. If it doesn't do it right, then what is the point of trying to convert.
Great tool.. some code work. :)
What's wrong with this simple line in VB.NET?
VB Code:
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles MyBase.Load Me.Text = "Version History" End Sub
VB Code:
using System; // Handles MyBase.Load private void Form2_Load(System.Object sender, System.EventArgs e) { Me.Text = "Version History"; }
Cheers,
McoreD
Indeed. What is wrong? Is this a test or are you getting a compile-time error?
I am sorry and nothing wrong with the VB.NET Code, it is the converted C#.NET Code which is wrong.
The VB.NET code was converted to Me.Text = "Version History"; which is wrong in Visual C#.
oh, ok. "Me" in VB is the same thing as "this" in C#. So change "Me.Text" to "this.Text".
thank you; :)Quote:
Originally posted by Mike Hildner
oh, ok. "Me" in VB is the same thing as "this" in C#. So change "Me.Text" to "this.Text".
My point was, the tool did conversions of far more advanced code:
for example:
VB Code:
private string myGetText(string strName) { try { // get the current assembly System.Reflection.Assembly oAsm = System.Reflection.Assembly.GetExecutingAssembly(); System.IO.Stream oStrm = oAsm.GetManifestResourceStream(oAsm.GetName().Name + "." + strName); // read contents of embedded file System.IO.StreamReader oRdr = new System.IO.StreamReader(oStrm); return oRdr.ReadToEnd(); } catch (Exception ex) { throw ex; } }
But the tool failed to do simple VB.NET code like
VB Code:
Me.Text = "Version History"
Cheers,
McoreD
Yeah, there's a few conversion tools out there, none of which are perfect. I've played with a couple of them, but really have found no need to convert to/from VB.NET from/to C#. Snippets are easy enough to do yourself, and complete classes can just be used as is.