You should try with this free online tool:
http://www.developerfusion.com/tools/convert/csharp-to-vb/
It converts C# to VB.net (and vice versa) and has served me well in the past, apart from some rare unhandled cases it has always done a correct conversion for me.
As for analyzing your code: if you don’t include the original C# to make a comparison it’s quite pointless…
EDIT: after seing the original code.
I see your VB method Handles btnUpload.Click
explicitly, something your C# method doesn’t seem to do.
I’m assuming this is an ASP.net website. Does your button declaration in the ASP file look something like this:
<asp:Button runat="server" ID="btnUpload" OnClick="btnUpload_Click"/>
?
In that case, it’s normal that it gets called twice: one time because the button declares explicitly that its OnClick
event should be handled by the btnUpload_Click
method, the second time because the method itself declares statically that it handles the button’s OnClick
event.
Either remove the OnClick="btnUpload_Click"
from your ASP code or remove Handles btnUpload.Click
from the method signature (I would suggest the second option, as it makes the backend code more reusable)
6
solved Converting c# to VB [closed]