Solved

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

Posted on 2006-11-27
7
510 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

707 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

16 Experts available now in Live!

Get 1:1 Help Now