Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Manipulating bits
I have two questions:
1) How do you separately read the bits in a byte/word? For example, I want to read the two MSB's of a word, each into a separate variable. How do I do this? 2) Is there a way to actually write out a number in binary in VB? For example, instead of saying X = 8, can you write it in binary as X = 00001000? If so, what is format you have to write it in? Thanks. Sunny |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Manipulating bits
Sunny,
Set a reference to ATPVBAEN.xls, then use something like: Sub test() Dim i As Integer For i = 0 To 2 ^ 8 MsgBox "The number " & i & " in Binary is " _ & Dec2Bin(i, 8) & Chr(10) & _ "And it's MSB is " & Left(Dec2Bin(i, 8), 1) & Chr(10) & _ "And it's 2nd MSB is " & Mid(Dec2Bin(i, 8), 2, 1) Next i End Sub HTH, Bernie MS Excel MVP "Sunny" wrote in message ... I have two questions: 1) How do you separately read the bits in a byte/word? For example, I want to read the two MSB's of a word, each into a separate variable. How do I do this? 2) Is there a way to actually write out a number in binary in VB? For example, instead of saying X = 8, can you write it in binary as X = 00001000? If so, what is format you have to write it in? Thanks. Sunny |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Charting more than 255 bits of data | Charts and Charting in Excel | |||
3 bits of data | Excel Discussion (Misc queries) | |||
How to match bits to a certain value | Excel Worksheet Functions | |||
=Dec2bin can you increase the number bits please | Excel Discussion (Misc queries) | |||
BIN2DEC bits 0-5 then 6-15 | Excel Worksheet Functions |