Results 1 to 17 of 17

Thread: C# To Vb.net

  1. #1

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    C# To Vb.net

    HI EVERY1
    I'm really wondering if there is any program that has the ability to convert VB.NET Code to C# or vice versa , like upgrading VB6 TO VB.NET

    Thanx guys

  2. #2
    Addicted Member Sheppe's Avatar
    Join Date
    Sep 2002
    Location
    Kelowna, BC
    Posts
    245

    Re: C# To Vb.net

    Originally posted by pirate
    HI EVERY1
    I'm really wondering if there is any program that has the ability to convert VB.NET Code to C# or vice versa , like upgrading VB6 TO VB.NET

    Thanx guys
    Why do you want to do that? They can interoperate.
    [vbcode]
    On Error Goto Hell
    [/vbcode]
    Sheppe Pharis, MCSD
    Check out http://www.vb-faq.com
    Click here for access to the free Code-Express source code and component sharing network for VB6
    Want a better way to skin your .NET applications? Click here!

  3. #3

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Well , I know that . Sometimes I find C# CODE and want ,for example a peice of that CODE in VB.NET .
    No body answered yet .
    thanx

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    You should just learn the C# syntax and translate it yourself, I think that is what most people are doing. Its really not hard.

    I'll start you off:
    VB Code:
    1. 'declaring a variable in vb
    2. Dim MyVar As Integer
    3. 'goes: [variablename] As [Type]
    4.  
    5. 'now in C#
    6. Integer MyVar;
    7. 'goes: [Type] [variablename];
    8. 'the semicolon is the line terminator in C# so just about every line has it at the end

  5. #5

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Edneeis
    You should just learn the C# syntax and translate it yourself, I think that is what most people are doing. Its really not hard.

    I'll start you off:
    VB Code:
    1. 'declaring a variable in vb
    2. Dim MyVar As Integer
    3. 'goes: [variablename] As [Type]
    4.  
    5. 'now in C#
    6. Integer MyVar;
    7. 'goes: [Type] [variablename];
    8. 'the semicolon is the line terminator in C# so just about every line has it at the end
    ______________________________________________

    thanx Edneeis .
    I found a lot of sites talking about C# for beginners but hoped I can find learning "C# in comparsion to VB". Just like the way you posted it .

  6. #6

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    one more question
    if a vb project contained 10 lines of code , then after converting to C# must be 10 lines too ?

  7. #7
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Maybe C# sometimes has more lines but usually less words:

    VB Code:
    1. 'VB line count=7
    2. Dim item As String
    3. For Each item In Items
    4.     If item="MyItem" Then
    5.         Msgbox("I Found It")
    6.         Exit For
    7.     End If
    8. Next
    9.  
    10. //C# line count=7
    11. foreach (string item in Items)
    12. {
    13.    if (item=="MyItem")
    14.    {
    15.         MessageBox.Show("I Found It");
    16.         //I don't think C# has an Exit For command
    17.    }
    18. }

    Somethings are more lines because of the {} structure but that might be the only thing on a line. Also somethings are shorter or longer (i.e. doesn't need a seperate line in C# to declare the For item, but each Case in a Select Case needs a break; statement).

  8. #8
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Instead of exit for, it is break in C#:
    VB Code:
    1. //C# line count=7
    2. foreach (string item in Items)
    3. {
    4.    if (item=="MyItem")
    5.    {
    6.         MessageBox.Show("I Found It");
    7.         break;
    8.    }
    9. }

    Also, when you type break in the IDE, it will show you which loop it is breaking out of by making it bold. I think that is pretty cool.

  9. #9
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    And just so you know, you have some flexibility with your coding style. C# doesn't care about white space. Since you use the ; at the end of a statement, you can seperate or compress your code to what ever you like. Example:
    Code:
    foreach (string item in Items){if (item=="MyItem"){MessageBox.Show("I Found It");break;}}
    Doesn't look very readable though.

  10. #10
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    u can do that in vb too use the :

    MsgBox("") : MsgBox("")

  11. #11
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Didn't know that....

  12. #12

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    thanx all for the posts .I started learning C# . BYE BYE

  13. #13
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    yea...2 weeks ago i started switching from vb.net to C#...although at start it looked like a mess and ugly now i got used and already preferr it to vb.net

  14. #14

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    IF you have long xp in VB.NET then you swiched to C# , do you think 2 weeks enough to master both C# & VB.NET since both are similar

  15. #15
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Not a chance in hell that you can master any language in two weeks..

  16. #16

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    what if I said 2 years - Would be easy job

  17. #17
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    im reading a 900page book..i already had experience in vb.net so it's just a matter of sintax

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