Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

Rated
Read 31,324 times

Related Categories

Binary to Decimal Convertor

Sweet

A simple function to convert Binary numbers to Decimal numbers.

Function Bin2Dec(Num As String) As Long
  Dim n As Integer
     n = Len(Num) - 1      a = n
     Do While n > -1
        x = Mid(Num, ((a + 1) - n), 1)
        Bin2Dec = IIf((x = "1"), Bin2Dec + (2 ^ (n)), Bin2Dec)
        n = n - 1
     Loop
End Function

Comments

  • Posted by breeze on 31 Mar 2005

    :confused: please some one help me!!!!! i'm meant to creat a calculator that can add subtract, multiply and divide and gives the answer in Decimal....

    in Visual Basic! i have no idea on how to go a...

  • Say What?

    Posted by Demonizer on 28 May 2003

    I don't mean to offend you , but that is quite messy.....
    The Below code will offer you your Flexability and your Fast Execution
    The Fact is, I know more then i get paid to know.... I'll give it to ...

  • BinaryToHexadecimal conversion

    Posted by jstout on 17 Mar 2003

    x isn't defined as local so might cause a problem if you had a global variable called x.

    How about a recursive definition?

    If the binary number string to be converted is "" then
    the value is ...