Help Converting Some C# Code to Visual Basic...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Vagabond Software

    #1

    Help Converting Some C# Code to Visual Basic...

    We're talking 2005 for both languages. Left, Top, Right, Bottom, Height, and
    Width are Integers.

    C# version:
    public override int GetHashCode()
    {
    return Left ^ ((Top << 13) | (Top >0x13))
    ^ ((Width << 0x1a) | (Width >6))
    ^ ((Height << 7) | (Height >0x19));
    }

    My VB2005 version:
    Public Overrides Function GetHashCode() As Integer
    Return Left ^ ((Top << 13) OR (Top >0x13)) _
    ^ ((Width << 0x1a) OR (Width >6)) _
    ^ ((Height << 7) OR (Height >0x19))
    End Function

    I'm seeing a couple of errors, but I think they are all related to the area
    around 0x13. Any help would be greatly appreciated.

    Carl


  • Tom Shelton

    #2
    Re: Help Converting Some C# Code to Visual Basic...

    On May 3, 9:18 am, "Vagabond Software" <vagabondsw.. .@-X-gmail.com>
    wrote:
    We're talking 2005 for both languages. Left, Top, Right, Bottom, Height, and
    Width are Integers.
    >
    C# version:
    public override int GetHashCode()
    {
    return Left ^ ((Top << 13) | (Top >0x13))
    ^ ((Width << 0x1a) | (Width >6))
    ^ ((Height << 7) | (Height >0x19));
    }
    >
    My VB2005 version:
    Public Overrides Function GetHashCode() As Integer
    Return Left ^ ((Top << 13) OR (Top >0x13)) _
    ^ ((Width << 0x1a) OR (Width >6)) _
    ^ ((Height << 7) OR (Height >0x19))
    End Function
    >
    I'm seeing a couple of errors, but I think they are all related to the area
    around 0x13. Any help would be greatly appreciated.
    >
    Carl

    change the 0x to &H.

    --
    Tom Shelton

    Comment

    • Vagabond Software

      #3
      Re: Help Converting Some C# Code to Visual Basic...

      "Tom Shelton" <tom_shelton@co mcast.netwrote in message
      news:1178206818 .579523.215190@ e65g2000hsc.goo glegroups.com.. .
      On May 3, 9:18 am, "Vagabond Software" <vagabondsw.. .@-X-gmail.com>
      wrote:
      >We're talking 2005 for both languages. Left, Top, Right, Bottom, Height,
      >and
      >Width are Integers.
      >>
      >C# version:
      > public override int GetHashCode()
      > {
      > return Left ^ ((Top << 13) | (Top >0x13))
      > ^ ((Width << 0x1a) | (Width >6))
      > ^ ((Height << 7) | (Height >0x19));
      > }
      >>
      >My VB2005 version:
      > Public Overrides Function GetHashCode() As Integer
      > Return Left ^ ((Top << 13) OR (Top >0x13)) _
      > ^ ((Width << 0x1a) OR (Width >6)) _
      > ^ ((Height << 7) OR (Height >0x19))
      > End Function
      >>
      >I'm seeing a couple of errors, but I think they are all related to the
      >area
      >around 0x13. Any help would be greatly appreciated.
      >>
      >Carl
      >
      >
      change the 0x to &H.
      >
      --
      Tom Shelton
      >
      Thanks Time, that did the trick.

      Carl


      Comment

      • Mattias Sjögren

        #4
        Re: Help Converting Some C# Code to Visual Basic...

        >C# version:
        public override int GetHashCode()
        {
        return Left ^ ((Top << 13) | (Top >0x13))
        ^ ((Width << 0x1a) | (Width >6))
        ^ ((Height << 7) | (Height >0x19));
        }
        >
        >My VB2005 version:
        Public Overrides Function GetHashCode() As Integer
        Return Left ^ ((Top << 13) OR (Top >0x13)) _
        ^ ((Width << 0x1a) OR (Width >6)) _
        ^ ((Height << 7) OR (Height >0x19))
        End Function
        In addition to what Tom wrote...

        The ^ operator in C# performs an XOR operation, whereas in VB it is
        the "power of" operator. So make sure you replace ^ with Xor.


        Mattias

        --
        Mattias Sjögren [C# MVP] mattias @ mvps.org
        http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
        Please reply only to the newsgroup.

        Comment

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

          #5
          Re: Help Converting Some C# Code to Visual Basic...

          See Mattias' comment. There's no way that using "^" will yield the same
          results.
          --
          David Anton
          Source code converters: Convert between C#, C++, Java, and VB with the most accurate and reliable source code converters

          Instant C#: VB to C# converter
          Instant VB: C# to VB converter
          Instant C++: C#/VB to C++ converter
          Instant Python: C#/VB to Python converter


          "Vagabond Software" wrote:
          "Tom Shelton" <tom_shelton@co mcast.netwrote in message
          news:1178206818 .579523.215190@ e65g2000hsc.goo glegroups.com.. .
          On May 3, 9:18 am, "Vagabond Software" <vagabondsw.. .@-X-gmail.com>
          wrote:
          We're talking 2005 for both languages. Left, Top, Right, Bottom, Height,
          and
          Width are Integers.
          >
          C# version:
          public override int GetHashCode()
          {
          return Left ^ ((Top << 13) | (Top >0x13))
          ^ ((Width << 0x1a) | (Width >6))
          ^ ((Height << 7) | (Height >0x19));
          }
          >
          My VB2005 version:
          Public Overrides Function GetHashCode() As Integer
          Return Left ^ ((Top << 13) OR (Top >0x13)) _
          ^ ((Width << 0x1a) OR (Width >6)) _
          ^ ((Height << 7) OR (Height >0x19))
          End Function
          >
          I'm seeing a couple of errors, but I think they are all related to the
          area
          around 0x13. Any help would be greatly appreciated.
          >
          Carl

          change the 0x to &H.

          --
          Tom Shelton
          >
          Thanks Time, that did the trick.
          >
          Carl
          >
          >
          >

          Comment

          • Vagabond Software

            #6
            Re: Help Converting Some C# Code to Visual Basic...

            "Mattias Sjögren" <mattias.dont.w ant.spam@mvps.o rgwrote in message
            news:u%23tA$iaj HHA.4704@TK2MSF TNGP06.phx.gbl. ..
            C# version:
            > public override int GetHashCode()
            > {
            > return Left ^ ((Top << 13) | (Top >0x13))
            > ^ ((Width << 0x1a) | (Width >6))
            > ^ ((Height << 7) | (Height >0x19));
            > }
            >>
            >>My VB2005 version:
            > Public Overrides Function GetHashCode() As Integer
            > Return Left ^ ((Top << 13) OR (Top >0x13)) _
            > ^ ((Width << 0x1a) OR (Width >6)) _
            > ^ ((Height << 7) OR (Height >0x19))
            > End Function
            >
            In addition to what Tom wrote...
            >
            The ^ operator in C# performs an XOR operation, whereas in VB it is
            the "power of" operator. So make sure you replace ^ with Xor.
            >
            >
            Mattias
            >
            --
            Thanks Matt, that resolved a conversion error I was getting (and
            subsequently improperly handling).

            Carl


            Comment

            • per9000

              #7
              Re: Help Converting Some C# Code to Visual Basic...

              On 3 Maj, 17:18, "Vagabond Software" <vagabondsw.. .@-X-gmail.com>
              wrote:
              We're talking 2005 for both languages. [...]
              VB.2005 is aka VB.NET?

              Perhaps you already know this but you can get a lot of help using a
              Lutz Roeder's Reflector:


              It analyzes the common intermediate language and turns it into source
              code; f.x. C#, VB.NET and so on. It is really helpful when converting
              from one .NET language to another. And just for peeking at source code
              in general.

              [:)]-|--<

              --

              Per Erik Strandberg
              ..NET Architect - Optimization
              Tomlab Optimization Inc.


              Comment

              Working...