convert a decimal value to binary

Hi,

How can I convert a decimal value to binary and then assign each bit of the word to it's own image that will represent a hi/low state? The images on the form will change their background color which will lighten or darken depending on their hi/low state.

Ken
[438 byte] By [kennm] at [2007-12-29]
# 1

Lets start with one issue at a time...

To convert a number to its binary representation you can use the convert class..

Dim L As Long = 11

Dim x As String = Convert.ToString(L, 2)

Debug.Print(x) '1011

However to convert a Decimal number you will have to create your own algorithm

DMan1 at 2007-9-4 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 2

"To convert a number to its binary representation you can use the convert class.."

Dman,

Thank you for maintaining distinctions that are important for computer scientists to communicate with each each. I think the people who are in a position to teach have an obligation to do that.

I appreciate it that you say "code" instead of scripts. I appreciate it that you recognize and maintain needed distinctions.

ReneeC at 2007-9-4 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 3

Thank you Dman.

After converting a number to its binary representation how can I grab an individual bit, lets say the second LSB bit of 10010111.

Ken

kennm at 2007-9-4 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 4

Dim BinaryString As String = "10010111"

Dim SecondLSB As String = BinaryString.Substring(BinaryString.Length - 2, 1)

DMan1 at 2007-9-4 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...