PDA

Click to See Complete Forum and Search --> : Copy VB.NET source code to C# projects


weaver04
Oct 3rd, 2004, 02:50 PM
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

hellswraith
Oct 3rd, 2004, 11:32 PM
Tried it on one of the most common things:

MsgBox("Hello World")

and it doesn't work.

Cander
Oct 5th, 2004, 01:10 PM
Well duh. msgbox is a VB6 compatability thing. So they probably ignored it. MessageBox.Show is the "proper" .NET way.

:afrog:

morpheus5
Oct 31st, 2004, 10:38 AM
but most of the books stated that Msgbox(text) is command for message box

Mike Hildner
Oct 31st, 2004, 03:42 PM
Originally posted by morpheus5
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.

hellswraith
Nov 1st, 2004, 10:19 PM
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.

~*McoreD*~
Nov 18th, 2004, 06:36 PM
Great tool.. some code work. :)

What's wrong with this simple line in VB.NET?

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load

Me.Text = "Version History"

End Sub

using System;

// Handles MyBase.Load
private void Form2_Load(System.Object sender, System.EventArgs e)
{

Me.Text = "Version History";

}


Cheers,
McoreD

Mike Hildner
Nov 19th, 2004, 10:43 PM
Indeed. What is wrong? Is this a test or are you getting a compile-time error?

~*McoreD*~
Nov 19th, 2004, 11:03 PM
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#.

Mike Hildner
Nov 19th, 2004, 11:08 PM
oh, ok. "Me" in VB is the same thing as "this" in C#. So change "Me.Text" to "this.Text".

~*McoreD*~
Nov 19th, 2004, 11:15 PM
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".

thank you; :)

My point was, the tool did conversions of far more advanced code:

for example:

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

Me.Text = "Version History"

Cheers,
McoreD

Mike Hildner
Nov 20th, 2004, 04:09 PM
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.