Convert Binary Number Into Decimal Number In PowerBuilder
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | //==================================================================== // Function: f_bintodec() //-------------------------------------------------------------------- // Description: Convert Binary number into Decimal number //-------------------------------------------------------------------- // Arguments: // value string sBin //-------------------------------------------------------------------- // Returns: integer //-------------------------------------------------------------------- // Usage: Integer iResult = f_bintodec("10110000") //==================================================================== Int iDec, i, n sBin = Reverse(sBin) n = 1 For i = 1 To Len(sBin) iDec += Long(Mid(sBin, i, 1)) * n n = 2 * n Next Return iDec |
Good Luck!