- Home
·
- Math/Dates
·
- I made these functions to convert ASCII to Binary, Binary to ASCII, Decimal to Binary and Binary to
I made these functions to convert ASCII to Binary, Binary to ASCII, Decimal to Binary and Binary to
I made these functions to convert ASCII to Binary, Binary to ASCII, Decimal to Binary and Binary to Decimal.
Rate I made these functions to convert ASCII to Binary, Binary to ASCII, Decimal to Binary and Binary to
(1(1 Vote))
Dim BinAsc As String
Dim BinDec(7, 1) As String
Dim AscBin As String
Public Function DectoBin(Number As Double)
For i = 0 To 7
Number = Number / 2
If Number - Fix(Number) = 0.5 Then
Bin(i) = 1
Else
Bin(i) = 0
End If
If Number - Fix(Number) = 0.5 Then
Number = Number - 0.5
End If
Next i
DectoBin = Bin(7) & Bin(6) & Bin(5) & Bin(4) & Bin(3) & Bin(2) & Bin(1) & Bin(0)
End Function
Public Function BintoDec(BinNum As String)
Dec = 0
For i = 0 To 7
power = 2 ^ i
BinDec(7 - i, 0) = power
Next i
For i = 0 To 7
BinDec(i, 1) = Mid(BinNum, i + 1, 1)
Next i
For i = 0 To 7
If BinDec(i, 1) = 1 Then
Dec = Dec + BinDec(i, 0)
End If
Next i
BintoDec = Dec
End Function
Public Function AsctoBin(aString As String)
BinAsc = ""
For it = 1 To Len(aString)
BinAsc = BinAsc & DectoBin(Asc((Mid(aString, it, 1))))
Next it
AsctoBin = BinAsc
End Function
Public Function BintoAsc(bString As String)
AscBin = ""
For it = 1 To Len(bString) Step 8
AscBin = AscBin & Chr(BintoDec(Mid(bString, it, 8)))
Next it
BintoAsc = AscBin
End Function
I made these functions to convert ASCII to Binary, Binary to ASCII, Decimal to Binary and Binary to Comments
No comments yet — be the first to post one!
Post a Comment