Results 1 to 5 of 5

Thread: C# to VB .NET tips

  1. #1

    Thread Starter
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913

    C# to VB .NET tips

    Thought I would share a few tips with you guys on C# to VB .NET conversion. You will note that alot of examples are in C# so knowing these will help you when looking at C# code to convert it to VB .NET

    First subroutines

    If you see something like this
    Code:
    public void Hello()
    {
    
    }
    that is a subroutine

    just change it to

    Code:
    Public Sub Hello()
    
    End Sub
    variables
    if you see something like this
    Code:
    string lala;
    that is how you declare variables. The first word is the data type, and the second is the variable name
    so in VB

    Code:
    Dim lala As String
    the C# decalre can also begin with public/private/friend like in VB.

    variables are assigned the same way

    lala = "hello";

    if you see using, that is the same as Imports in VB

    if statements are pretty closely the same, just when you see

    if(whatever)
    {

    }

    the {} denotes a block if so you would change that to

    Code:
    If whatever Then
    
    End If

    foreach is the same as For Each basically


    functions

    if you see this

    Code:
    public string Hello()
    {
    
    }
    that is a function that returns a string. Pretty easy to guess what that look like in VB.

    there are of course some other thigns here and there, but this is enough info to help you scan through C# code to get some needed code for your VB .NET app most of the time
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  2. #2
    Lively Member
    Join Date
    Aug 2001
    Posts
    65
    Hmmm... thanks Cander, That was helpfull. I'm having enough trouble with VB.NET, very steep learning curve for me at least.

    Do you have any other little tips like that?

  3. #3

    Thread Starter
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    I have lots tips I can share. What in particular would like to see some tips on?
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  4. #4
    Lively Member
    Join Date
    Aug 2001
    Posts
    65
    Anything really, arrays, is one, i believe there are no control arrays now in VB.NET i use these extensively in my programs and i'm wondering how i'm going to get around them, not sure i understand why they were taken out.

    I've gone to your web site and registered on you forum but i haven't had time to look around, i'll try sometime later.

  5. #5
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    u should use addhandles

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width