Convert a Byte value to Numeric - Possible?

Discussion in 'ASP General' started by Arnold Shore, Oct 9, 2003.

  1. Arnold Shore

    Arnold Shore Guest

    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
     
    Arnold Shore, Oct 9, 2003
    #1
    1. Advertising

  2. Arnold Shore

    dlbjr Guest

    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
     
    dlbjr, Oct 9, 2003
    #2
    1. Advertising

  3. Arnold Shore

    dlbjr Guest

    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
     
    dlbjr, Oct 9, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    20
    Views:
    9,806
    licebmi
    Sep 7, 2009
  2. Polaris431
    Replies:
    8
    Views:
    761
    SM Ryan
    Dec 4, 2006
  3. Replies:
    5
    Views:
    946
    X-Centric
    Jun 30, 2005
  4. Arnold Shore

    How to Convert a Byte to its Numeric Value?

    Arnold Shore, Oct 9, 2003, in forum: ASP General
    Replies:
    1
    Views:
    123
    Arnold Shore
    Oct 9, 2003
  5. Arnold Shore

    Converting a Byte Value to its Numeric Value

    Arnold Shore, Oct 9, 2003, in forum: ASP General
    Replies:
    0
    Views:
    128
    Arnold Shore
    Oct 9, 2003
Loading...

Share This Page