473,326 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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
May 3 '07 #1
6 1330
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

May 3 '07 #2
"Tom Shelton" <to*********@comcast.netwrote in message
news:11**********************@e65g2000hsc.googlegr oups.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
May 3 '07 #3
>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.
May 3 '07 #4
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" <to*********@comcast.netwrote in message
news:11**********************@e65g2000hsc.googlegr oups.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
May 3 '07 #5
"Mattias Sjögren" <ma********************@mvps.orgwrote in message
news:u%****************@TK2MSFTNGP06.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
May 4 '07 #6
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/

May 4 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: mustafa | last post by:
Dear sir , I have built my application in visual basic 6.0 and crystal Report8.5 , Now i migrated my application to VB.net using the upgrade wizard.My visual basic form is upgraded to vb.net...
6
by: mustafa | last post by:
Dear sir , I have built my application in visual basic 6.0 and crystal Report8.5 , Now i migrated my application to VB.net using the upgrade wizard.My visual basic form is upgraded to vb.net...
36
by: Cap'n Ahab | last post by:
I have used VB3 - VB6, so learning all this OO stuff is reasonably new to me (although I looked at Java a few years ago). Anyway, I thought I would write a small class to begin with, with a...
4
by: Chris Asaipillai | last post by:
Hi there My compay has a number of Visual Basic 6 applications which are front endeed onto either SQL Server or Microsoft Access databases. Now we are in process of planning to re-write these...
6
by: Sergey Poberezovskiy | last post by:
I have the following code in C# that I have trouble converting to VB(2.0): private delegate void openDialog(); private void openWindowsDialog(openDialog open) { Thread thread = new Thread(new...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.