Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Convert a Byte value to Numeric - Possible?

Reply
Thread Tools

Convert a Byte value to Numeric - Possible?

 
 
Arnold Shore
Guest
Posts: n/a
 
      10-09-2003
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


 
Reply With Quote
 
 
 
 
dlbjr
Guest
Posts: n/a
 
      10-09-2003
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

--
-dlbjr

Discerning resolutions for the alms


 
Reply With Quote
 
 
 
 
dlbjr
Guest
Posts: n/a
 
      10-09-2003
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

--
-dlbjr

Discerning resolutions for the alms


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
convert form byte[4] to Int32 while retaining the binary value of the byte array jeff@foundrymusic.com C++ 20 09-07-2009 08:54 PM
How to convert a 4 byte character string to its equivalent 4 byte integer value? Polaris431 C Programming 8 12-04-2006 07:00 AM
check if string contains numeric, and check string length of numeric value ief@specialfruit.be C++ 5 06-30-2005 01:08 PM
How to Convert a Byte to its Numeric Value? Arnold Shore ASP General 1 10-09-2003 01:49 AM
Converting a Byte Value to its Numeric Value Arnold Shore ASP General 0 10-09-2003 12:03 AM



Advertisments