Hertz Posted April 25, 2008 Report Posted April 25, 2008 This program convert Binary to text and text to binary. This program has one Form1 (Main.frm), textbox (Text1.Text), two button, (cmdConvtoBin and cmdConvtoText) and a module1 (Binary.bas)Acest program converteste din binar in text si invers.Acest program are un Form1(Main.frm,textbox(Text1.Text),doua butoane(cmdConvtoBin si cmdConvtoText) si un module1(Binary.bas)FormPrivate Sub cmdConvtoBin_Click() MainText = Text1.Text ConvertBin MainText Text1.Text = MainTextEnd SubPrivate Sub cmdConvtoText_Click() MainText = Text1.Text ConvertToText MainText Text1.Text = MainTextEnd SubPrivate Sub Form_Load() Text1.Text = "" End SubModulePublic MainText As StringPublic Sub ConvertToText(BinText As String) Dim BinChar As String Dim CharX As String Dim ConvertedMessage As String Dim Z As Integer Dim NewChar As Integer Dim Bx As Integer Dim BBx As Integer For Bx = 1 To Len(BinText) BinChar = Mid(BinText, Bx, 8) Z = 128 NewChar = 0 For BBx = 1 To 8 CharX = Mid(BinChar, BBx, 1) If CharX = "1" Then NewChar = NewChar + Z Z = Z / 2 Else Z = Z / 2 End If Next BBx ConvertedMessage = ConvertedMessage & Chr(NewChar) Bx = Bx + 7 Next Bx BinText = ConvertedMessageEnd SubPublic Sub ConvertBin(TheString As String) Dim C As Integer Dim DD As Integer Dim EE As Integer Dim BinArray(7) As String Dim TempString As String Dim NewTheString As String For C = 1 To Len(TheString) DD = Asc(Mid(TheString, C, 1)) BinArray(7) = DD Mod 2 DD = DD / 2 BinArray(6) = DD Mod 2 DD = DD / 2 BinArray(5) = DD Mod 2 DD = DD / 2 BinArray(4) = DD Mod 2 DD = DD / 2 BinArray(3) = DD Mod 2 DD = DD / 2 BinArray(2) = DD Mod 2 DD = DD / 2 BinArray(1) = DD Mod 2 DD = DD / 2 BinArray(0) = DD Mod 2 For EE = 0 To UBound(BinArray) TempString = TempString + BinArray(EE) Next EE NewTheString = NewTheString + TempString TempString = "" Next C TheString = NewTheString NewTheString = ""End Sub Quote