471,348 Members | 1,582 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,348 software developers and data experts.

vb.net: managing bit and bytes

Hi,
I need to set the value of 8 bit variables separately and then put them into
a byte variable.

Is it possible using VB.NET. How?

Thank you very much.
Jul 21 '05 #1
2 5892
Try "or" :

MsgBox(Hex$(1 Or 2 or 4 Or 8))

--

"Federico Caselli" <Fe*************@discussions.microsoft.com> a écrit dans
le message de news:8D**********************************@microsof t.com...
Hi,
I need to set the value of 8 bit variables separately and then put them into a byte variable.

Is it possible using VB.NET. How?

Thank you very much.

Jul 21 '05 #2
You'll need to "shift" them. AFAIK the fist operator is not currently
available (I believe this will show up in VB 2005).

Meanwhile and unless you need to do that a fair amount of time you could do
:

allBits=bit1+bit2*2+bit3*4+bit4*8 etc...

Another option would be to see if the BitArray class could help :
http://msdn.microsoft.com/library/de...mberstopic.asp
(never usde it but rmember to have seen it)

Patrice
--

"Federico Caselli" <Fe*************@discussions.microsoft.com> a écrit dans
le message de news:4A**********************************@microsof t.com...
Thank you for answering, but I'd need to set boolean values of bits
separately, something like:

bit1 = 1
bit2 = 0
bit3 = 1
...
bit8 = 0

and then put them into a unique byte variabile in the right order.

Thank you

Jul 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Georgeo Pulikkathara[MS] | last post: by
4 posts views Thread by Shawn Brock | last post: by
10 posts views Thread by Kleenex | last post: by
reply views Thread by Georgeo Pulikkathara[MS] | last post: by
16 posts views Thread by Kent | last post: by
2 posts views Thread by Federico Caselli | last post: by
reply views Thread by GreggTB | last post: by
6 posts views Thread by Jerry Spence1 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.