Solved

How do I convert a character to a bit array in VB.NET?

Posted on 2006-11-27
7
514 Views
Last Modified: 2012-05-05
How do I convert a character to a bit array in VB.NET 2005?  If you know how to convert a string to a bit array, that would solve my problem just as well...

Thanks in advance!
0
Comment
Question by:stev0931
  • 4
  • 3
7 Comments
 
LVL 16

Accepted Solution

by:
Hillwaaa earned 125 total points
ID: 18024973
Hi stev0931,

Try this:

Dim myBitArray As New BitArray(System.Text.Encoding.ASCII.GetBytes("a"))

Cheers,
Hillwaaa
0
 

Author Comment

by:stev0931
ID: 18024999
Thanks!
0
 

Author Comment

by:stev0931
ID: 18025193
Also, do you know how to convert the bitarray back into a string?

For example, the bitarray may be 0001011010100110001101100011011011110110, in which case I need "hello", which is the ascii representation of the bitarray using the code above...
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 16

Expert Comment

by:Hillwaaa
ID: 18025355
Did you get an answer on this - I thought I saw a separate question but now I can't see it?
0
 

Author Comment

by:stev0931
ID: 18025382
I ended up writing a function to convert a bitstream to binary and then used a built-in function to get a string from that - 50 lines of code later, it's working.  Not the most elegant solution, but it works :)

Thanks!
0
 
LVL 16

Expert Comment

by:Hillwaaa
ID: 18025400
No worries - long and short of what I could figure is that there is no easy solution to doing bitarray back to string.  The only other thing I found of interest was http://www.codeproject.com/useritems/JIBitArray.asp?df=100&forumid=316116&exp=0&select=1530092 - discussing a few bitarray related issues.  It's in C# but you get the idea :)
0
 

Author Comment

by:stev0931
ID: 18025404
Thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

896 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now