Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Charting more than 255 bits of data PVakerling Charts and Charting in Excel 7 April 21st 23 06:11 PM
3 bits of data BimboUK Excel Discussion (Misc queries) 2 June 16th 09 03:19 AM
How to match bits to a certain value Matt Excel Worksheet Functions 1 August 23rd 06 06:24 AM
=Dec2bin can you increase the number bits please WAT Excel Discussion (Misc queries) 0 July 29th 06 01:20 AM
BIN2DEC bits 0-5 then 6-15 Jim Excel Worksheet Functions 5 May 28th 06 06:24 PM


All times are GMT +1. The time now is 01:54 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"