How to use VB to C# conversion service (4) - declaration-section mode
declaration-section mode converts the declaration section (module variables and user-defined types (Type)) at the beginning of the file.
1. Open the conversion service page.
2. Select 'declaration section'
3. Paste your VB code from the declaration-section into the left textarea "VB code".
4. Press the middle ">>" button.
5. The translated C# code will be displayed on the right side textarea.
Since the C# code is incomplete in the image, the full code snippet is provided below for accurate conversion.
class UsrRecord01 public string FirstName; //First name public string LastName; //last name public int Age; //age public void LSet(string s) { } public string ToLSet() { string s = ""; s += this.FirstName.ToString(); s += this.LastName.ToString(); s += this.Age.ToString(); return s; } } class Program { public static int mdlVar01; }
Additional notes on the generated code:
- User-defined types are converted to C# classes.
- The LSet() and ToLSet() methods are created to handle VB's LSet statement, but you can be removed if you are not needed.
- Module-level variables are converted to member variables within the Program class. You can either modify the Program class or extract the variable definition section for use.