Skip to main content
GameDev.net gamedev.net
🔒 Locked

DWord in VB?

Started by Prozak Mar 10, 2004 at 12:56 PM 2 replies 8.9k views
Original Post
Prozak
Prozak
Hi, Visual Basic 6 seems to have only 1 data type with 2 bytes, the Integer, which run from -32k to +32k.... I need a DWord type that runs from 0 to 65K, and unsigned integer so to speak... How does one define this under VB? Salsa cooked it, your eyes eat it!
[Hugo Ferreira][Positronic Dreams][Colibri 3D Engine][Entropy HL2 MOD][My DevDiary]
[Yann L.][Enginuity] [Penny Arcade] [MSDN][VS RoadMap][Humus][BSPs][UGP][NeHe]
                          Prozak - The GameDever formally known as pentium3id
alexmoura
alexmoura
I think vb6 only has 3 integer types - a byte (8 bit unsigned), an integer (16 bit signed) and a long (32 bit signed) - you probably will have to use the long if all you need is the range, or the integer if you''re doing declare statements (if you pass -1 in an integer to an api that is expecting an unsigned 16 bit integer, he''ll see it as 65535)

"I woke up sweating and clutching my pillow. Thankfully the powerful and reassuring visage of Optimus Prime staring back at me from my pillow case served to ease my frayed nerves. Like the giant robotic father I never had he always knows just what to say" - Gabe, Penny-Arcade

Alexandre Moura
Prozak
Prozak
So my best course of action if to use longs (4bytes), and convert them to integers (2bytes) before dumping to the file right?...

VB is so cool as a RAD tool... they should have more basic data types, or at least let us define signed/unsigned ones...

Salsa cooked it, your eyes eat it!
[Hugo Ferreira][Positronic Dreams][Colibri 3D Engine][Entropy HL2 MOD][My DevDiary]
[Yann L.][Enginuity] [Penny Arcade] [MSDN][VS RoadMap][Humus][BSPs][UGP][NeHe]
                          Prozak - The GameDever formally known as pentium3id
alexmoura
alexmoura
I don't think you can do that assignment directly - you'll get an overflow when you go over 32000, you may have to simulate two's complement to get a value that will fit in the integer.

I haven't worked that much with vb6, so I don't really know if there is a way to automatically do that conversion - if you don't care too much about the size, I'd just use the longs in the file instead.

(And vb .net does have a few more basic types - it will include unsigned integer native types in the next version)

[edited by - alexmoura on March 11, 2004 4:52:47 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.