Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Pro Visual Basic 2005
Pro Visual Basic 2005 For advanced Visual Basic coders working in version 2005. Beginning-level questions will be redirected to other forums, including Beginning VB 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro Visual Basic 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old March 20th, 2007, 05:31 AM
Registered User
Join Date: Feb 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default convert 4 bytes to bit array

For some project tame and data are stored in 4 bytes where the first 6 bits are the seconds, next 6 are the minutes and so on. So if i could isolate each byte in an array , maybe than i can convert the first 6 bits to a byte and get it to figures. But i don't find a way how to do this. Could anyone help ?

Old March 21st, 2007, 05:40 PM
Authorized User
Join Date: Dec 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to maxl

Hey Vinny_68

I was interested in your problem and figured out how to do perform some of the functionality. If you want to convert your Byte array (assuming its already an Byte array) to an array of Bits, use this statement:

Dim mybits() as new System.Collections.BitArray(your_byte_array)

After this, converting some of these Bits to a specific data type im not really sure how to do yet. There is a class; System.BitConverter that will convert a batch of bits to various data types. All the methods i saw in there only accept a minimum of 16 bits for the conversion to the smallest data type. Im sure there is a way to get this done though. I will post more info once i learn more.

Also, you might have to pad your 6 bits with dummy data for some conversion methods, or those might do that for you. Im not a expert in this area at all, im just speculating.

Similar Threads
Thread Thread Starter Forum Replies Last Post
convert arraylist into array mohitbhutani C# 2 June 14th, 2011 04:00 AM
hw to convert string to array asfakahmed Java Basics 1 May 11th, 2008 06:39 AM
64 Bit - Issue in 64 bit IIS calling Win32 API Hubman General .NET 1 August 24th, 2006 09:19 AM
convert bytes[] into base64binary in asp.net bharat_agarwal XSLT 1 June 20th, 2006 02:04 AM
Bytes doa-wnloaded vincentvdm Classic ASP Professional 0 August 17th, 2003 01:52 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.