Imports System.IO Module Module1 Function ConvertToBinary(ByVal num As Integer) As String Dim binvalue As String binvalue = "" Do While num > 0 binvalue = Trim(Str(num Mod 2)) & binvalue num = num \ 2 Loop binvalue = binvalue.PadLeft(6, "0") Return binvalue End Function Sub Main() Dim fsIn As New FileStream("DATA52.txt", FileMode.Open, FileAccess.Read) Dim infile As New StreamReader(fsIn) Dim fsOut As New FileStream("OUT52.txt", FileMode.Create, FileAccess.Write) Dim outfile As New StreamWriter(fsOut) Dim x As Integer Dim y As Integer Dim s As String Dim bin6 As String Dim value As Integer Dim decoded As String Dim s8 As String Dim s8value As Integer For x = 1 To 5 s = infile.ReadLine bin6 = "" For y = 0 To s.Length - 1 Select Case s.Chars(y) Case "A" To "Z" value = AscW(s.Chars(y)) - 65 bin6 = bin6 + ConvertToBinary(value) Case "a" To "z" value = AscW(s.Chars(y)) - 97 + 26 bin6 = bin6 + ConvertToBinary(value) Case "0" To "9" value = Val(s.Chars(y)) + 52 bin6 = bin6 + ConvertToBinary(value) Case "+" bin6 = bin6 + "111110" Case "/" bin6 = bin6 + "111111" Case "=" bin6 = bin6 + "000000" End Select Next y decoded = "" Do While bin6.Length > 0 s8 = bin6.Substring(0, 8) s8value = Val(s8.Chars(0)) * 128 + Val(s8.Chars(1)) * 64 + Val(s8.Chars(2)) * 32 + Val(s8.Chars(3)) * 16 + Val(s8.Chars(4)) * 8 + Val(s8.Chars(5)) * 4 + Val(s8.Chars(6)) * 2 + Val(s8.Chars(7)) * 1 bin6 = bin6.Remove(0, 8) If s8value > 0 Then decoded = decoded + ChrW(s8value) End If Loop outfile.WriteLine(Trim(decoded)) Next x infile.Close() fsIn.Close() outfile.Close() fsOut.Close() End Sub End Module