?
Solved

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

Posted on 2006-11-27
7
Medium Priority
?
522 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
[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
  • 4
  • 3
7 Comments
 
LVL 16

Accepted Solution

by:
Hillwaaa earned 500 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
Independent Software Vendors: 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 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

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…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

719 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