Long (Int64) variable supports int32 data to do aritmetic.
But if you are working with unsigned values, Use Uint64.
Uint64 is no Cls Compliant, this warning if you expose public variables.
Hi, I'm using VB 2005, WinForms. I have an application that uses a lot of Hex values. Some of the value are in dWords format (00000000) and some are in qWord format(0000000000000000). I originally declared my variables as "String", which worked, but it lead to a lot of type conversions if I had to add values, and also improper formatting of outputs.
I think that the best thing I can do is go back and re-work some of the code before moving forward and declare my variables in a way that will work without having to do so much type conversion.
My values might look somewhat like this:
00C00200
or
0000A10000500000
My question is this: What variable "Type" would be best for Hex values/variables? - Would it be "Double", would it be "Long", would it be "String" and simply deal with the conversion issue?
Thanks for your help,
Fulano
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Leave 'em as Strings. You can convert them to Int64s like this:
Dim HexString As String = "0000A10000500000"
Dim HexInt64 As Int64 = Convert.ToInt64(HexString,
Debug.Print(HexString & " Hex = " & HexInt64 & " Decimal")
Now you can perform calculations with them as Int64s.
When you need them back in Hex Format, use something like:
Dim HexString2 As String = HexInt64.ToString("X").Pad
Debug.Print("HexString2 = " & HexString2)
The output was:
0000A10000500000 Hex = 177021377314816 Decimal
HexString2 = 0000A10000500000
Hi All, I tried each of your suggestions, but none seem to really work.
Lets try an example in VB:
Dim x as String = "00800000" < This worked for me.
However,
Dim x as Integer = 0x30405021 << Does not work
Dim x as Int32 = 0x30405021 << Does not work
Dim x as Int64 = 0x30405021 << Does not work
Dim x as Long = 30405021 << Does not work
Dim x as Double = 30405021 << Does not work
Dim x as Long = &H00500000 << Simply converts my Hex value to decimal = 20480
Thanks,
Fulano
Business Accounts
Answer for Membership
by: Omego2KPosted on 2009-10-31 at 12:56:28ID: 25711274
a double word is an integer.
int x = [your hex value here];
e.g. int x = 0x30405021;
you can also use short and long for hex values. It just depends how large it is.