Wrox Programmer Forums
|
VS.NET 2002/2003 Discussions about the Visual Studio.NET programming environment, the 2002 (1.0) and 2003 (1.1). ** Please don't post code questions here ** For issues specific to a particular language in .NET, please see the other forum categories.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VS.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 12th, 2003, 09:48 AM
Authorized User
 
Join Date: Jun 2003
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help - Convert from C# to VB.Net

I am having trouble converting this C# code to VB.Net. Can someone please help me? I am fluent in VB.Net and am trying to learn C# but I don't understand what is going on here completely, and don't know how to convert it to VB.Net to understand it better.

Code:
 cksum = (cksum >> 16) + (cksum & 0xffff);
       cksum += (cksum >> 16);
       return (UInt16)(~cksum);
Thanks you in advance,

Christopher P. Cooper

It's important for us to explain to our nation that life is important. It's not only life of babies, but it's life of children living in, you know, the dark dungeons of the Internet."— George W. Bush - Arlington Heights, Ill., Oct. 24, 2000
__________________
Vote Kerry/Edwards 2004

It\'s important for us to explain to our nation that life is important. It\'s not only life of babies, but it\'s life of children living in, you know, the dark dungeons of the Internet.\"— George W. Bush - Arlington Heights, Ill., Oct. 24, 2000
 
Old July 20th, 2003, 10:06 AM
Authorized User
 
Join Date: Jun 2003
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi
I had a look at your piece of code. This code is working with bits (DWord). I am only average VB & VB.Net dev and still can not find way of doing it yet.
At present, I can help only with code breakdown meaning and I hope it would be helpful to you.

1.(cksum >> 16) means cksum's bits is shifted 16 places to the right.
2.(cksum & 0xffff) means cksum AND with hex value FFFF (binary - 111111111111)
3.(~cksum) means cksum added one compliment to its value ie, 2 (10) will equals to 3 (11). When you change it to 16 bits unsigned value (UInt16) this infacts turn it to a negative number.
I wonder what is this code for any how, you probably know C# syntax is similar to C/C++ so it can handle the low level programming. As VB is more to higher level language, I guess I can not find way of doing it in VB yet, from my point of view, this code is more suited to C# or C/C++. If you can do it please let me knows ... good luck.

Cheers
Kasie






Similar Threads
Thread Thread Starter Forum Replies Last Post
convert C++ syntax to VB .NET hendyhanusin VB.NET 2002/2003 Basics 0 July 19th, 2007 09:52 PM
convert string to datetime in VB.net lisabb ASP.NET 2.0 Basics 3 June 19th, 2007 06:52 AM
convert PHP to VB.NET or C# eugz VB.NET 4 April 24th, 2007 01:12 PM
convert dsr file from vb to vb.net Shashi001 VB Components 1 September 22nd, 2006 12:24 PM
Syntax Help - Convert C# to VB.NET ank2go ASP.NET 1.0 and 1.1 Professional 3 July 7th, 2004 09:33 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.