Convert integer to bit

C

cmdolcet69

I have the following created in vb 2003:

Public Bitvalue as byte()

Public Sub Upload ()
dim i as integer =0

for i = 0 to 4095
bitvalue=bitconverted.getbytes(i)

bitvalue(0)
bitvalue(1)

next

end Sub


When i look at my bitvalue (0) and bitvalue (1) if my i = 152 then
my bitvalue (0) should be H8 and my bitvalue (1) should be H9 in hex
for.... however i only see bitvalue(0) is 152


Can anyone help?
 
R

rowe_newsgroups

I have the following created in vb 2003:

Public Bitvalue as byte()

Public Sub Upload ()
dim i as integer =0

for i = 0 to 4095
bitvalue=bitconverted.getbytes(i)

bitvalue(0)
bitvalue(1)

next

end Sub

When i look at my bitvalue (0) and bitvalue (1)    if my i = 152 then
my bitvalue (0) should be H8 and my bitvalue (1) should be H9 in hex
for.... however i only see bitvalue(0) is 152

Can anyone help?

I'm guessing it's converting it to a byte, but when you look at it
through the watch window / drop down it's just displaying it as an
integer.

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
 
H

Herfried K. Wagner [MVP]

rowe_newsgroups said:
I'm guessing it's converting it to a byte, but when you look at it
through the watch window / drop down it's just displaying it as an
integer.

That's what I guess too. Note that the watch window provides a context menu
entry to turn to hexadecimal display of numbers.
 
C

Cor Ligthert[MVP]

Hi

Maybe I miss something, but I don't understand your code, I see something
that is named bitconverted comming from the air, is it possible to explain
where that fields is comming from?

Cor
 
J

James Hahn

Use this:
Dim Bitvalue As Byte()
Dim A As String
Dim i As Integer = 0

For i = 0 To 4095
Bitvalue = BitConverter.GetBytes(i)

A = Hex(Bitvalue(0))
A = Hex(Bitvalue(1))

Next

but I do not understand why you expect 152 to be H08,H09. 152 is H98. I
suspect you want this code to do something quite different. Is this an
endian problem?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top