Convert a Byte value to Numeric - Possible?

A

Arnold Shore

Among the usual suspects:

1. Asc requires (apparently) an ansi value as argument. I'm dealing with the
HO bits in a byte.
2. Cint requires a numeric expression as argument. I have a byte available -
I haven't found a conversion function.

Thanks, all.

AS
 
D

dlbjr

Function BinToDec(strBin)
dim lngResult
dim intIndex

lngResult = 0
for intIndex = len(strBin) to 1 step -1
strDigit = mid(strBin, intIndex, 1)
select case strDigit
case "1"
lngResult = lngResult + (2 ^ (len(strBin)-intIndex))
case else
lngResult = 0
intIndex = 0
end select
next
BinToDec = lngResult
End Function
 
D

dlbjr

Function DecToBin(intDec)
dim strResult
dim intValue
dim intExp

strResult = ""
intValue = intDEC
intExp = 65536
while intExp >= 1
if intValue >= intExp then
intValue = intValue - intExp
strResult = strResult & "1"
else
strResult = strResult & "0"
end if
intExp = intExp / 2
wend
DecToBin = strResult
End Function
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top