Public Function BIN(Dec As Long) As String
BIN = ""
Do While Dec > 0
BIN = Dec Mod 2 & BIN
Dec = Dec \ 2
Loop
If Len(BIN) < 5 Then BIN = "0" + BIN
If Len(BIN) < 5 Then BIN = "0" + BIN
If Len(BIN) < 5 Then BIN = "0" + BIN
If Len(BIN) < 5 Then BIN = "0" + BIN
End Function
Public Function BIN3(Dec As Long) As String
BIN3 = ""
Do While Dec > 0
BIN3 = Dec Mod 5 & BIN3
Dec = Dec \ 5
Loop
If Len(BIN3) < 3 Then BIN3 = "0" + BIN3
If Len(BIN3) < 3 Then BIN3 = "0" + BIN3
If Len(BIN3) < 3 Then BIN3 = "0" + BIN3
End Function
Private Sub Command1_Click()
a = Replace(Text1.Text, " ", "")
a = UCase(a)
b = -Int(-Len(a) * 3 / 8)
u = ""
For i = 1 To b
u = u + BIN(Val(Asc(Mid(a, i, 1))) - 64)
Next i
For i = b + 1 To Len(a)
d2 = d2 + BIN3(Val(Asc(Mid(a, i, 1))) - 64)
Next i
For i = 1 To Len(u)
If Len(d2) < Len(u) Then
d2 = d2 + "0"
End If
Next i
For i = 1 To Len(u)
c = c + Str(Val(Mid(u, i, 1)) * 5 + Val(Mid(d2, i, 1)))
Next i
c = Replace(c, " ", "")
Text2.Text = c
End Sub
BIN = ""
Do While Dec > 0
BIN = Dec Mod 2 & BIN
Dec = Dec \ 2
Loop
If Len(BIN) < 5 Then BIN = "0" + BIN
If Len(BIN) < 5 Then BIN = "0" + BIN
If Len(BIN) < 5 Then BIN = "0" + BIN
If Len(BIN) < 5 Then BIN = "0" + BIN
End Function
Public Function BIN3(Dec As Long) As String
BIN3 = ""
Do While Dec > 0
BIN3 = Dec Mod 5 & BIN3
Dec = Dec \ 5
Loop
If Len(BIN3) < 3 Then BIN3 = "0" + BIN3
If Len(BIN3) < 3 Then BIN3 = "0" + BIN3
If Len(BIN3) < 3 Then BIN3 = "0" + BIN3
End Function
Private Sub Command1_Click()
a = Replace(Text1.Text, " ", "")
a = UCase(a)
b = -Int(-Len(a) * 3 / 8)
u = ""
For i = 1 To b
u = u + BIN(Val(Asc(Mid(a, i, 1))) - 64)
Next i
For i = b + 1 To Len(a)
d2 = d2 + BIN3(Val(Asc(Mid(a, i, 1))) - 64)
Next i
For i = 1 To Len(u)
If Len(d2) < Len(u) Then
d2 = d2 + "0"
End If
Next i
For i = 1 To Len(u)
c = c + Str(Val(Mid(u, i, 1)) * 5 + Val(Mid(d2, i, 1)))
Next i
c = Replace(c, " ", "")
Text2.Text = c
End Sub