Solved

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

Posted on 2006-11-27
7
518 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 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Convert VB web project to C# 3 66
Need to Interpret Json in Vb.net ( .net 3.5  framework) 11 52
Set arraylist as datatable 2 29
Convert a string to date 4 40
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
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…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

751 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