C# to VB.NET

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Binyuan Sun
    New Member
    • Jan 2012
    • 1

    C# to VB.NET

    How do I convert "string lol = "112233aabb cc"; int num = string[0];"
  • PsychoCoder
    Recognized Expert Contributor
    • Jul 2010
    • 465

    #2
    First and foremost that code will cause errors, simply because lol is a string not an array so you cannot access it the way you are in num. What you would have to do is make make lol into a string array, like this

    Code:
    string lol = "112233aabbcc";
    string[] array = lol.Split(new char[] {','});
    You next problem is the item at index 0 is a string not an int so that would make your code puke. You need to convert it to an int first, like this:

    Code:
    int temp = 0;
                
    if(int.TryParse(array[0], out temp))
    {
        int num = temp;
    }
    So now we have working C# code, now we can convert it to VB.NET:

    Code:
    Dim lol As String = "112233aabbcc"
    Dim array As String() = lol.Split(New Char() {","C})
    Dim temp As Integer = 0
    Dim num As Integer
    
    If Integer.TryParse(array(0), temp) Then
    	num = temp
    End If
    NOTE: This was written in notepad because I have no IDE open so it's just a sample of what you're looking for and this should give you a good start

    Comment

    • Hannodb
      New Member
      • Feb 2011
      • 3

      #3
      Go to google, search "Convert C# to VB". The very first site is:http://www.developerfusion.com/tools.../csharp-to-vb/ Simply paste your C# in and press Convert. It's a very good tool, and haven't let me down yet.

      Comment

      Working...