This is a migrated thread and some comments may be shown as answers.

C# to VB batch conversion (minor issues)

0 Answers 68 Views
Code Converter
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Mych
Top achievements
Rank 1
Mych asked on 13 Sep 2012, 09:45 AM
This is the first time I have used the converter and have found it to be great although I did still have to do some minor changes in order for the converted code to work. Listing here to help others...

1. HANDLES not added:
e.g. protected void Page_Load(object sender, EventArgs e) converted to
       Protected Sub Page_Load(ByVal sender as Object, ByVal e as System.EventArgs)
in order to work I had to add Handles to the end of each event sub line. In the case above I added Handles Me.Load 

2. Concatenation of strings:
e.g.  string today = "";
today = yy + mm + dd + "_Returns_" + DateTime.Now.ToLongTimeString().Replace(":", "_") + Session["User"].ToString();
converted to:
Dim today As String = ""
today = yy + mm + dd + "_Returns_" + DateTime.Now.ToLongTimeString().Replace(":", "_") + Session["User"].ToString()
       In some cases using + to join two strings in VB will work but if this case the first three element are integers and you get a CAST error. I ended up going through the code and replacing + with & (Don't do this globaly though as it will replace the + in mathematical calculations).
The line above became
today = yy & mm & dd & "_Returns_" & DateTime.Now.ToLongTimeString().Replace(":", "_") & Session["User"].ToString() It could also be written as:
today = yy.ToString() + mm.ToString() + dd.ToString() + "_Returns_" + DateTime.Now.ToLongTimeString().Replace(":", "_") + Session["User"].ToString()

Otherwise a very good conversion. Converted 32 C# files and made the above alterations and was done within an hour.
Tags
Code Converter
Asked by
Mych
Top achievements
Rank 1
Share this question
or