473,396 Members | 1,814 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,396 software developers and data experts.

Data Type Conversion bug??

With VS2003 I get the following problem:

This works in C#...
{
ulong u=0xF070061073000000; <-no problem initializing variable to
this value
Console.WriteLine(u);
}
But this fails in VB.NET...
Dim u As UInt64 = Convert.ToUInt64(&HF070061073000000) <-Overflow error
here!
Console.WriteLine(u)
Why am I able to initialize the variable in C#, yet intializing to the same
value in VB.NET dies? A ulong and a UInt64 are both the same underlying
framework datatype, a System.UInt64, so what's the problem?

Am I missing something here? Is there a workaround?

Randall

Jul 19 '05 #1
2 4463
Randall,
VB.NET does not understand unsigned numbers!

Using ildasm.exe: VB.NET is attempting to call Convert.ToUInt64(Int64).

Seeing as you are attempting to put a massively negative number (long) into
a unsigned value, it is throwing the exception.

C# works because C# understands unsigned numbers. CSharp is calling
Convert.ToUInt64(UInt64).

Remember in VB.NET (&HF070061073000000) is a Long value, there is no ULong
in VB.NET (yet).

As it stands now you will need to wait for the next version of VB.NET
("Whidbey" (2004)) to get support for unsigned values.
http://msdn.microsoft.com/vstudio/pr...o/roadmap.aspx

Hope this helps
Jay

"Randall Banning" <randall.b spam @ not rogers.com> wrote in message
news:_e*********************@news01.bloor.is.net.c able.rogers.com...
With VS2003 I get the following problem:

This works in C#...
{
ulong u=0xF070061073000000; <-no problem initializing variable to
this value
Console.WriteLine(u);
}
But this fails in VB.NET...
Dim u As UInt64 = Convert.ToUInt64(&HF070061073000000) <-Overflow error
here!
Console.WriteLine(u)
Why am I able to initialize the variable in C#, yet intializing to the same value in VB.NET dies? A ulong and a UInt64 are both the same underlying
framework datatype, a System.UInt64, so what's the problem?

Am I missing something here? Is there a workaround?

Randall

Jul 19 '05 #2
Thanks Jay for the answer. I'm not saying I like it <g>, but it's an answer.

Ok, what I'll do is build what I want into a separate C# DLL then reference
that in my VB project. It's not an ideal solution but it'll hold me until
2004.

Randall

"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message
news:eu**************@TK2MSFTNGP10.phx.gbl...
Randall,
VB.NET does not understand unsigned numbers!

Using ildasm.exe: VB.NET is attempting to call Convert.ToUInt64(Int64).

Seeing as you are attempting to put a massively negative number (long) into a unsigned value, it is throwing the exception.

C# works because C# understands unsigned numbers. CSharp is calling
Convert.ToUInt64(UInt64).

Remember in VB.NET (&HF070061073000000) is a Long value, there is no ULong
in VB.NET (yet).

As it stands now you will need to wait for the next version of VB.NET
("Whidbey" (2004)) to get support for unsigned values.
http://msdn.microsoft.com/vstudio/pr...o/roadmap.aspx

Hope this helps
Jay

"Randall Banning" <randall.b spam @ not rogers.com> wrote in message
news:_e*********************@news01.bloor.is.net.c able.rogers.com...
With VS2003 I get the following problem:

This works in C#...
{
ulong u=0xF070061073000000; <-no problem initializing variable to
this value
Console.WriteLine(u);
}
But this fails in VB.NET...
Dim u As UInt64 = Convert.ToUInt64(&HF070061073000000) <-Overflow error here!
Console.WriteLine(u)
Why am I able to initialize the variable in C#, yet intializing to the

same
value in VB.NET dies? A ulong and a UInt64 are both the same underlying
framework datatype, a System.UInt64, so what's the problem?

Am I missing something here? Is there a workaround?

Randall


Jul 19 '05 #3

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

Similar topics

21
by: Batista, Facundo | last post by:
Here I send it. Suggestions and all kinds of recomendations are more than welcomed. If it all goes ok, it'll be a PEP when I finish writing/modifying the code. Thank you. .. Facundo
9
by: Ksenia Marasanova | last post by:
Hi, I have a little problem with encoding. Was hoping maybe anyone can help me to solve it. There is some amount of data in a database (PG) that must be inserted into Excel sheet and emailed....
10
by: Zap | last post by:
Widespread opinion is that public data members are evil, because if you have to change the way the data is stored in your class you have to break the code accessing it, etc. After reading this...
1
by: Amir | last post by:
Hi all, I have a table called PTRANS with few columns (see create script below). I have created a view on top that this table VwTransaction (See below) I can now run this query without a...
6
by: New MSSQL DBA | last post by:
Hi all, we are now planning to upgrade our application from a non-unicode version to a unicode version. The application's backend is a SQL Server 2000 SP3. The concern is, existing business...
1
by: tony.fountaine | last post by:
I am working on a project to read a Bosch Measurement Data File (MDF). The file contains a number of blocks that can be read from the file using a baisc structure. For example the ID BLOCK is as...
19
by: scroopy | last post by:
Is it impossible in C++ to create an assignment operator for classes with const data? I want to do something like this class MyClass { const int m_iValue; public: MyClass(int...
5
by: Akaketwa | last post by:
guys help me on this rather nubish question.I have created a new data type in java and i also want to create a new data type object in db2 that will store the money data object. The money...
3
by: Trev | last post by:
Hi, I have a series of functions which do the following: ValidateData( args ); //args if of type ArrayList // Work out if the data is valid or not, and work out the type of args - int, string,...
1
by: SteveDouglas | last post by:
Hi all, I am currently writing an application in VB.NET that has a lot of controls (treeviews/listviews/labels and so forth) that represent "things" that need to be draggable from place to place,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.