Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Int to Bit Array?

Status
Not open for further replies.

ThatRickGuy

Programmer
Oct 12, 2001
3,841
US
I know I've seen the code before, but I can't seem to track it down at the moment. Anyone have a handy function to convert an integer to a bit array?

ie:
14 -> 1110

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
I could write one n a few minutes, but I'm sure you already have done that by now.

Christiaan Baes
Belgium

"My old site" - Me
 
You beat me to the post Chrissie :p

This is what I threw together:
Code:
Dim ia As Integer() = {role.Security}
Dim ba As New BitArray(ia)
If ba(1) Or ba(2) Or ba(3) Then
  'this role has edit, create, or delete access
End If

I must have fat fingered a few times before I first posted because I couldn't seem to find the BitArray class.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top