How To Convert ASCII To String In Visual Basic.?
-
I've found how to convert text entered to ASCII, but I cant seem to find how to decode the numbers. Heres my code(this is in the VB5 & 6 Textbook): Private strText As String Private strConvertedText As String Private strConvertedAscii As String 'Ends the program Private Sub cmdDone_Click() End End Sub 'Sets both options un checked on form start up Private Sub Form_Load() optEncode.Value = False optDecode.Value = False End Sub Private Sub optDecode_Click() End Sub 'Converts text the user entered, to ASCII code Private Sub optEncode_Click() Dim strText As String Dim strCurrentLetter As String Dim intLength As Integer Dim strConvertedText As String strText = txtText.Text For intLength = 1 To Len(strText) strCurrentLetter = Mid(strText, intLength, 1) Debug.Print strCurrentLetter strConvertedText = strConvertedText & Asc(strCurrentLetter) & " " Debug.Print strConvertedText Next intLength lblFinal.Caption = strConvertedText End Sub I need someone to give me the code for the optDecode option.
-
Answer:
The following code works. 'Ends the program Private Sub cmdDone_Click() End End Sub Dim strText As String 'Dim strConvertedText As String Dim strConvertedAscii As String Private Sub Label1_Click() End Sub Private Sub optDecode_Click() Dim strDecoded As String Dim Str1, Str2 As String Dim Flag1, Cnt As Integer Do While Flag1 = 0 Flag1 = 1 Cnt = Cnt + 1 If Mid(lblFinal.Caption, Cnt, 1) <> " " Then Str1 = Str1 & Mid(lblFinal.Caption, Cnt, 1) Flag1 = 0 Else Str2 = Str2 & Chr(Val(Str1)) If Cnt < Len(lblFinal.Caption) Then Flag1 = 0 Str1 = " " End If End If Loop lblDecoded.Caption = Str2 End Sub 'Converts text the user entered, to ASCII code Private Sub optEncode_Click() Dim strText As String Dim strCurrentLetter As String Dim intLength As Integer Dim strConvertedText As String strText = txtText.Text For intLength = 1 To Len(strText) strCurrentLetter = Mid(strText, intLength, 1) Debug.Print strCurrentLetter strConvertedText = strConvertedText & Asc(strCurrentLetter) & " " Debug.Print strConvertedText Next intLength lblFinal.Caption = strConvertedText End Sub 'Sets both options un checked on form start up Private Sub Form_Load() optEncode.Value = False optDecode.Value = False End Sub TexMav
Jonathan at Yahoo! Answers Visit the source
Related Q & A:
- How to Convert Json date string to more readable date format?Best solution by SharePoint
- How to convert UNICODE to ASCII?Best solution by Stack Overflow
- How to move string in visual studio?Best solution by visuallocalizer.codeplex.com
- How do you use the Contains Function in Visual Basic?Best solution by go4expert.com
- How do I output from one form to another in Visual Basic?Best solution by support.microsoft.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.