By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,474 Members | 1,283 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,474 IT Pros & Developers. It's quick & easy.

Counter for Bit / Flag

P: n/a
Option Explicit
Dim b As Byte

Private Sub test()
Dim z As Long
Use 5
Use 6
Use 6
For z = 0 To 7
Debug.Print z, Used(z)
Next z
End Sub

Public Sub Use(ByVal n As Long)
b = b Or 2 ^ n
End Sub

Public Function Used(ByVal n As Long) As Boolean
Used = b And 2 ^ n
End Function

The function Used() tells us which numbers have been used.
How would you keep track of the number of times they have been used (in the
sample 5->1, 6->2)?
--
Lyle
--
Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Lyle Fairfield <Lo******@FFDBA.Com> wrote in
news:Xn*******************@130.133.1.4:
Option Explicit
Dim b As Byte

Private Sub test()
Dim z As Long
Use 5
Use 6
Use 6
For z = 0 To 7
Debug.Print z, Used(z)
Next z
End Sub

Public Sub Use(ByVal n As Long)
b = b Or 2 ^ n
End Sub

Public Function Used(ByVal n As Long) As Boolean
Used = b And 2 ^ n
End Function

The function Used() tells us which numbers have been used.
How would you keep track of the number of times they have been
used (in the sample 5->1, 6->2)?

declare a public array of int in test, increment the applicable
subscript in used.
--
Bob Quintal

PA is y I've altered my email address.
Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.