Public Function Bintodec(Val As String) As Long Dim Lens, T1, T2 As Long Lens = Len(Val) y = 1 T2 = 0 For i = 1 To (Lens) T1 = Int(Mid(Val, i, 1)) T2 = T2 + (T1 * y) y = (y * 2) Next i Bintodec = T2 End Function
Public Function Dectobin(Val As String) As String Dim T1, T2 As String T2 = "" Again: Val = Val / 2 T1 = Val - Int(Val) Val = Int(Val) If T1 = 0.5 Then T1 = "1" Else T1 = "0" End If T2 = T2 + T1 If Val = 0 Then GoTo EndLoop GoTo Again EndLoop: Dectobin = T2 End Function