Solved

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

Posted on 2006-11-27
7
517 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

 
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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
VB: Convert 2 dates to specific format 24 53
VB.NET 2008 Publish Error 2 34
Obtain cell value using column ID in DataGrid using VB.NET 2 25
Vb.net threads keep increasing 2 37
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

821 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