PC Review


Reply
Thread Tools Rate Thread

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

 
 
Vagabond Software
Guest
Posts: n/a
 
      3rd May 2007
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


 
Reply With Quote
 
 
 
 
Tom Shelton
Guest
Posts: n/a
 
      3rd May 2007
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

 
Reply With Quote
 
 
 
 
Vagabond Software
Guest
Posts: n/a
 
      3rd May 2007
"Tom Shelton" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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


 
Reply With Quote
 
Mattias Sjögren
Guest
Posts: n/a
 
      3rd May 2007
>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.
 
Reply With Quote
 
=?Utf-8?B?RGF2aWQgQW50b24=?=
Guest
Posts: n/a
 
      3rd May 2007
See Mattias' comment. There's no way that using "^" will yield the same
results.
--
David Anton
www.tangiblesoftwaresolutions.com
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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
>
>
>

 
Reply With Quote
 
Vagabond Software
Guest
Posts: n/a
 
      4th May 2007
"Mattias Sjögren" <(E-Mail Removed)> wrote in message
news:u%23tA$(E-Mail Removed)...
> >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


 
Reply With Quote
 
per9000
Guest
Posts: n/a
 
      4th May 2007
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:
http://www.aisto.com/roeder/dotnet/

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.
http://tomopt.com/tomnet/

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Some help on converting some code from Allen Browne search2000 kostas Microsoft Access VBA Modules 1 18th Sep 2008 11:41 AM
Needs help converting some pseudo code into VB code williameis Microsoft Excel Programming 2 21st Dec 2006 08:46 PM
Converting windows forms from Visual Studio 2003 to Visual Studio =?Utf-8?B?U2F0aXNoIEJhYnUgRGFzYXJp?= Microsoft Dot NET Framework Forms 1 28th Dec 2005 04:18 PM
Calling DLL export function(unmanaged visual c++ code) from managed code(Visual c#,.net) =?Utf-8?B?c2Vhc2g=?= Microsoft C# .NET 1 4th Feb 2004 11:16 AM
Help! Help! Help! Help! Help! Help! Help! Help! Help! Help! Help! Help! Help! -$- Windows XP Internet Explorer 2 21st Dec 2003 11:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:09 PM.