Convert Binary to Decimal and vice versa
//Function which converts decimal to binary
Private Function Dec2Bin(ByVal dec As Double) As String
Dec2Bin = “”
While dec >= 1
Dec2Bin = IIf(dec Mod 2 = 0, “0″, “1″) & Dec2Bin
dec = dec / 2
Wend
End Function
//Function which converts binary to decimal
Private Function Bin2Dec(ByVal str As String) As Double
Dim x As Integer
Bin2Dec = 0
For x = 1 To Len(str)
Bin2Dec = Bin2Dec + (CInt(Mid(str, x, 1)) * (2 ^ (Len(str) - x)))
Next x
End Function
