C# to VB.NET

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?=

    C# to VB.NET

    Hi all,

    always, I have developed with C#. Now, new project with VS 2005 + SQL
    SERVER, and VB.NET like language.

    Any help about vb.net ? For example, posters with VB.NET syntax, comparing
    with C# syntax, etc

    Code project sampe for VB.NET ??

    thanks in advance...greet ings
    --





  • Joergen Bech

    #2
    Re: C# to VB.NET


    Conversion from C# to VB.Net is much easier than the other
    way around, as C# is more "pure" and in some ways could
    be considered a subset of VB.Net.

    Or, before this devolves into a flame war, let me put it another
    way: VB.Net programmers are likely to use elements from the
    Microsoft.Visua lBasic (and even Microsoft.Visua lBasic.Compatib ility)
    namespaces. Translating such code to C# can be problematic
    at times. C# developers are less like to use elements that cannot
    be directly translated into their VB.Net equivalents.

    There are plenty of articles comparing the two languages, e.g.



    Also check the external links section at the bottom of


    There are also free and commercial language conversion tools
    which you can use to convert snippets - at least as a starting point,
    e.g.


    In general, I do not recommend the use of such tools unless your
    understanding of the target language is sufficient to spot the
    deficiencies and issues in the translated code.

    You might also benefit from comparing code in these samples,
    which are available in C# and VB.Net versions:


    Regards,

    Joergen Bech



    On Wed, 21 May 2008 02:27:01 -0700, Alhambra Eidos Kiquenet
    <AlhambraEidosK iquenet@discuss ions.microsoft. comwrote:
    >Hi all,
    >
    >always, I have developed with C#. Now, new project with VS 2005 + SQL
    >SERVER, and VB.NET like language.
    >
    >Any help about vb.net ? For example, posters with VB.NET syntax, comparing
    >with C# syntax, etc
    >
    >Code project sampe for VB.NET ??
    >
    >thanks in advance...greet ings

    Comment

    • =?ISO-8859-1?Q?Mathias_W=FChrmann?=

      #3
      Re: C# to VB.NET

      Hi Joergen,

      Joergen Bech <jbech<NOSPAM >@ schrieb:
      There are also free and commercial language conversion tools which
      you can use to convert snippets - at least as a starting point, e.g.

      In general, I do not recommend the use of such tools unless your
      understanding of the target language is sufficient to spot the
      deficiencies and issues in the translated code.
      ACK, this reminds me of my favorite post from
      microsoft.publi c.de.german.ent wickler.donet.v b newsgroup:

      <original post, translated>
      I need help in translating a line of C# code to VB.NET. The freely
      available conversion tools yielded different results...

      here is the code (num2 and num1 are of type int):
      num2 = ((num2 << 5) + num2) ^ num1;

      Results from the conversion tools:
      num2 = CInt((num2 << 5 + num2) ^ num1)
      num2 = (((num2 + 5) + num2) Or num1)
      </original post>

      <answer>
      num2 = ((num2 << 5) + num2) ^ num1
      </answer>

      Do I need to say more? *g*


      Regards,

      Mathias Wuehrmann
      --
      flexact.de steht zum Verkauf, kontaktieren Sie uns noch heute für ein kostenloses Angebot.Füllen Sie das untenstehende Formular aus und Sie erhalten ein kostenloses Angebot.

      Comment

      • Joergen Bech

        #4
        Re: C# to VB.NET

        On Wed, 21 May 2008 12:32:35 +0200, Mathias Wührmann
        <usenet@flexact .dewrote:
        >Hi Joergen,
        >
        >Joergen Bech <jbech<NOSPAM >@ schrieb:
        >There are also free and commercial language conversion tools which
        >you can use to convert snippets - at least as a starting point, e.g.
        >http://labs.developerfusion.co.uk/co...arp-to-vb.aspx
        >In general, I do not recommend the use of such tools unless your
        >understandin g of the target language is sufficient to spot the
        >deficiencies and issues in the translated code.
        >
        >ACK, this reminds me of my favorite post from
        >microsoft.publ ic.de.german.en twickler.donet. vb newsgroup:
        >
        ><original post, translated>
        >I need help in translating a line of C# code to VB.NET. The freely
        >available conversion tools yielded different results...
        >
        >here is the code (num2 and num1 are of type int):
        >num2 = ((num2 << 5) + num2) ^ num1;
        >
        >Results from the conversion tools:
        >num2 = CInt((num2 << 5 + num2) ^ num1)
        >num2 = (((num2 + 5) + num2) Or num1)
        ></original post>
        >
        ><answer>
        >num2 = ((num2 << 5) + num2) ^ num1
        ></answer>
        >
        >Do I need to say more? *g*
        >
        >
        >Regards,
        >
        >Mathias Wuehrmann
        That's pretty funny.

        And if you paste the same code into the converter I
        linked to (or http://converter.telerik.com/), we get

        num2 = ((num2 << 5) + num2) Xor num1

        If we grab another one at


        we get

        num2 = ((num2 < 5) + num2) ^ num1

        Yes, only one "<" instead of "<<" and "Xor" instead of "^".

        Actually, I believe the first conversion to be the correct one -
        not the one you provided. As far as I am able to read the online
        documentation, the "^" character in C# means logical XOR,
        whereas the same character in VB.Net means "raises a number
        to the power of another number". (Please correct me if I am wrong).

        Only proves my point that one needs to be able to evaluate
        the output - which kind of obviates the need for such converters.

        Occasionally I write something in one language, compile it, and
        then use Reflector to decompile it to another language, just to see
        what it looks like. That approach has its own pitfalls.
        I wonder if Reflector still chokes when attempting to decompile a
        function that uses On Error Resume Next? :) Haven't tried that one
        for a long time.

        Regards,

        Joergen Bech



        Comment

        • Joergen Bech

          #5
          Re: C# to VB.NET

          On Wed, 21 May 2008 13:13:44 +0200, Joergen Bech
          <jbech<NOSPAM>@ <NOSPAM>post1.t ele.dkwrote:
          >On Wed, 21 May 2008 12:32:35 +0200, Mathias Wührmann
          ><usenet@flexac t.dewrote:
          ---snip---
          >we get
          >
          num2 = ((num2 < 5) + num2) ^ num1
          >
          >Yes, only one "<" instead of "<<" and "Xor" instead of "^".
          ---snip---

          Make that: and "^" instead of "Xor".

          Now I cannot even read what I am writing myself :(

          /JB



          Comment

          • =?Utf-8?B?RGF2aWQgQW50b24=?=

            #6
            Re: C# to VB.NET

            Ack - you have to have some idea of what is correct before you knock the
            tools - your 'correct' answer is wrong - the answer is (via Instant VB):
            num2 = ((num2 << 5) + num2) Xor num1

            Also, be aware than many of the online tools were done as a 'one-off' and
            are not maintained - but they are still available, giving all the converters
            a bad name. You can easily figure out which ones fit this description.
            --
            Source code converters: Convert between C#, C++, Java, and VB with the most accurate and reliable source code converters

            C++ to C#
            C++ to VB
            C++ to Java
            VB to Java
            Java to VB & C#
            Instant C#: VB to C#
            Instant VB: C# to VB
            Instant C++: VB, C#, or Java to C++/CLI


            "Mathias Wührmann" wrote:
            Hi Joergen,
            >
            Joergen Bech <jbech<NOSPAM >@ schrieb:
            There are also free and commercial language conversion tools which
            you can use to convert snippets - at least as a starting point, e.g.

            In general, I do not recommend the use of such tools unless your
            understanding of the target language is sufficient to spot the
            deficiencies and issues in the translated code.
            >
            ACK, this reminds me of my favorite post from
            microsoft.publi c.de.german.ent wickler.donet.v b newsgroup:
            >
            <original post, translated>
            I need help in translating a line of C# code to VB.NET. The freely
            available conversion tools yielded different results...
            >
            here is the code (num2 and num1 are of type int):
            num2 = ((num2 << 5) + num2) ^ num1;
            >
            Results from the conversion tools:
            num2 = CInt((num2 << 5 + num2) ^ num1)
            num2 = (((num2 + 5) + num2) Or num1)
            </original post>
            >
            <answer>
            num2 = ((num2 << 5) + num2) ^ num1
            </answer>
            >
            Do I need to say more? *g*
            >
            >
            Regards,
            >
            Mathias Wuehrmann
            --
            flexact.de steht zum Verkauf, kontaktieren Sie uns noch heute für ein kostenloses Angebot.Füllen Sie das untenstehende Formular aus und Sie erhalten ein kostenloses Angebot.

            >

            Comment

            • =?UTF-8?B?TWF0aGlhcyBXw7xocm1hbm4=?=

              #7
              Re: C# to VB.NET

              Hi David,

              David Anton schrieb:
              Ack - you have to have some idea of what is correct before you knock
              the tools - your 'correct' answer is wrong - the answer is (via
              Instant VB): num2 = ((num2 << 5) + num2) Xor num1
              thanks for getting this right. As you can see, my knowledge in C# is
              very limited either, so I wasn't aware of the differences of '^' in C#
              and VB.NET. ;-)

              Regards,

              Mathias Wuehrmann

              Comment

              Working...