Code

 
  VBScript Routines  
  Decimal to Binary
  Binary to Decimal
  Hex. to Decimal   Decimal to Hex.
 
JavaScript Routines
  setTimeout
  Rollovers
 
HTML
  Web Safe Colors
  Web Safe Color Picker

VBScript: Binary to Decimal Conversion

This function converts a binary value represented by a string of ones and zeros into a decimal value.

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 "0"
        ' do nothing
      case "1"
        lngResult = lngResult + (2 ^ (len(strBin)-intIndex))
      case else
        ' invalid binary digit, so the whole thing is invalid
        lngResult = 0
        intIndex = 0 ' stop the loop
    end select
  next

  BinToDec = lngResult
End Function

 

Tell me what you think