?
Solved

Bit setting in VB6

Posted on 2005-02-26
7
Medium Priority
?
425 Views
Last Modified: 2006-11-17
Part 1:

I have a map of 40,000 locations. Details of these locations are maintained in an Array.

I have tried using:

Type MyBitType
    bit(1 To 13) As Byte     '13 bytes = 13 x 8 =104 bit values
End Type

Type TypeMap
    X As Integer
   Y As Integer
   Visible() As MyBitType
End Type

Public Map As TypeMap

.....

ReDim Map.Visible(200, 200)

I am then able to set / clear the bit in Map.Visible(x,y) for each location

It works- bit is their a cleaner / faster way for setting 100 bits for each of the 40,000 locations.


Part 2:

I would the need to save / retrieve the bit data into an Access database field






0
Comment
Question by:lplayer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 8

Expert Comment

by:fatalXception
ID: 13411290
Do you mean that each map location ie an X/Y pair, also has 104 individual on/off flags that you want to keep track of?
It's just not 100% clear from the post.
What you have above, is one variable with
-One X value
-One Y value
-40,000 13 Byte values

I don't see how your 40,000 separate X/Y locations are stored?
0
 
LVL 1

Author Comment

by:lplayer
ID: 13411435
Sorry thats not the complete code, just an overview of the problem.

There should of couese be a
ReDim Map.X(200, 200)
ReDim Map.Y(200, 200)


To be clear, each map location is represented by an Array  accessed by X , Y ,(max x = 200, max y =200, thus giveing 40,000 map locations) and each location needs a flag represented by 100 Bits to indicate if that location is visible or not (by 100 users).
0
 
LVL 44

Assisted Solution

by:Arthur_Wood
Arthur_Wood earned 750 total points
ID: 13411640
rather than having your

Type MyBitType
    bit(1 To 13) As Byte     '13 bytes = 13 x 8 =104 bit values
End Type


I would make your 100 User Flags a String of 100 Characters (Y or N)

The trouble I see with your array approach is figuring out which bit in the 13 bytes belongs to which user.

Type MyBitTYpe
    bit as String*100
End Type


Then to clear the bits for all users


    bit=" "

Since the your bit type is a FIXED LENGTH string of 100 characters, all 100 are set to " ".

AW


0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:lplayer
ID: 13412173
But   surely the String*100 is greater memory use than bit(1 To 13) As Byte, and when I have 40,000 such records thats a problem.

I need to be able to use minimum memory which is 100 bits.

I easily can determine which bit is set with a bit test routine, and so I have no problem with that.

Essentially I need a bit type or an equivelent. I think VB.Net has it but not VB6




 
0
 
LVL 8

Accepted Solution

by:
fatalXception earned 750 total points
ID: 13412350
VB6 doesn't have anything smaller, so your initial decision looks best in terms of size.
In terms of storing in a DB, you would probably need to just store the integer equivalent value of each of the 13 bytes in 13 fields.
0
 
LVL 28

Expert Comment

by:Ark
ID: 13424672
Just a comment:
>>bit is their a cleaner / faster way<<
Wrong!
Since VB (as well as access) memory is dword aligned, fastest data type is long
0
 
LVL 1

Author Comment

by:lplayer
ID: 13424976
Ark - sorry

>>bit is their a cleaner / faster way<<
should have read:
>>but is their a cleaner / faster way?<<
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question