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:
What you need is the chr() function. It returns the character whos ASCII code is entered. E.g. chr(65) returns "A"
Jonathan at Yahoo! Answers Visit the source
Other answers
' On a side note, when you say " Heres my code(this is in the VB5 & 6 Textbook): " I have never used that book so I'm guessing you are trying to decode a word from a text box. ' use a for loop that passes a string value into a variable. You can also use an array, a do while ect.... ' I'm just using the for loop because it looks like that is wat you want to use. Dim ASCiiConverter as string 'this will be used to convert ASCII to its Int value Dim value = ASCiiConverter 'this will be your string value that the array assigns 'values to be converted ' This is inside a button click event For i As Integer = i To ASCiiConverter.Count - 1 ' I used a text box as the input and a list box to ' display the converted ASCII code Dim final As String = Mid(value, i + 1, 1) lstASCiiToInteger.Items.Add(Asc(final)) Next ---------------------------------------… ' This is a diffrent button click event i used to test the ASCii code Dim testASCII As Integer = txtTestASCII.Text lstBoxListTest.Items.Add(Chr(testASCII))
Joe
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.