ascii translator problemi don't even know where to start my teacher just skipped everythin
Page 1 of 1
11 Replies - 5894 Views - Last Post: 20 December 2006 - 11:14 AM
#1
ascii translator problem
Posted 19 December 2006 - 04:22 PM
Dim intNumber As Integer
Dim strInput As String
intNumber=2
strInput=txtInput.Text
lblTranslation.Caption=Asc(strInput+2)
Sorry that's honestly all I can figure out please help me. You can also instant message me at yahoo at the user ID: lokithe3rd
Replies To: ascii translator problem
#2
Re: ascii translator problem
Posted 19 December 2006 - 05:22 PM
Private Sub Text1_Change() Dim tekst_2$ tekst_2 = leia_2(UCase(Text1.Text), arv) Text2.Text = tekst_2 Text3.Text = leia_3(Split(tekst_2, ","), arv) End Sub Function leia_2(tekst_1, ByRef arv) For i = 1 To Len(tekst_1) tekst_2 = tekst_2 & "," & Asc(Mid(tekst_1, i, 1)) + 2 arv = arv + 1 Next i leia_2 = Replace(Replace(Replace(tekst_2, 91, 65), 92, 66), 34, 32) End Function Function leia_3(a, arv) For i = 1 To arv tekst_3 = tekst_3 & Chr(a(i)) Next i leia_3 = tekst_3 End Function
This post has been edited by m2s87: 19 December 2006 - 05:32 PM
#3
Re: ascii translator problem
Posted 19 December 2006 - 05:30 PM
m2s87, on 19 Dec, 2006 - 05:22 PM, said:
Private Sub Text1_Change() Dim tekst_2$ tekst_2 = leia_2(UCase(Text1.Text), arv) Text2.Text = tekst_2 Text3.Text = leia_3(Split(tekst_2, ","), arv) End Sub Function leia_2(tekst_1, ByRef arv) For i = 1 To Len(tekst_1) tekst_2 = tekst_2 & "," & Asc(Mid(tekst_1, i, 1)) arv = arv + 1 Next i leia_2 = Replace(Replace(tekst_2, 89, 65), 90, 66) End Function Function leia_3(a, arv) For i = 1 To arv tekst_3 = tekst_3 & Chr(a(i)) Next i leia_3 = tekst_3 End Function
what does all of that stand for I must be using a different version I use microsoft basic version 5 or 6 what is the tekst? thank you so musch by the way
#4
Re: ascii translator problem
Posted 19 December 2006 - 05:38 PM
Also it is always best to CONVERT a data type to the type of data you are dealing with.
You can do it all in one line, but it is easier to follow if you break it up.
lblTranslation.Caption=Str(Asc(Ucase(strInput)+2))
Dim myInputChar as String Dim intEncode as Integer Dim strThisLetter as String Dim intPosition as Integer ' Create a loop to go from the beginning of the text to the end. For intPosition = 0 to Len(txtMessage.text) ' Textbox allows input ' retrieve one single character from within the string myIputChar = Mid(txtMessage.text, intPosition,1) ' put conditional statements here to handle special characters ' and to store the converted value in intEncode ' output the converted character to a label, appending to end lblTranslation.Caption = lblTranslation.Caption & Str(intEncode) ' repeat untill end of txtMessage.text is reached. Next intPosition
Use VB Help and look up ASCII, it will show you the complete list of ASCII codes. 0-127 are considered STANDARD ASCII and codes 128 - 255 are considered EXTENDED ASCII
lokithe2nd, on 19 Dec, 2006 - 05:30 PM, said:
m2s87, on 19 Dec, 2006 - 05:22 PM, said:
Private Sub Text1_Change() Dim tekst_2$ tekst_2 = leia_2(UCase(Text1.Text), arv) Text2.Text = tekst_2 Text3.Text = leia_3(Split(tekst_2, ","), arv) End Sub Function leia_2(tekst_1, ByRef arv) For i = 1 To Len(tekst_1) tekst_2 = tekst_2 & "," & Asc(Mid(tekst_1, i, 1)) arv = arv + 1 Next i leia_2 = Replace(Replace(tekst_2, 89, 65), 90, 66) End Function Function leia_3(a, arv) For i = 1 To arv tekst_3 = tekst_3 & Chr(a(i)) Next i leia_3 = tekst_3 End Function
what does all of that stand for I must be using a different version I use microsoft basic version 5 or 6 what is the tekst? thank you so musch by the way
This is not the intent of this site, when you assist someone, explain to them what you are doing step by step and please do not do the entire work for them, let them learn. We are here to provide ASSISTANCE with UNDERSTANDING not to provide solutions, especially those which are obscure in their implementation.
This post has been edited by KeyWiz: 19 December 2006 - 05:41 PM
#5
Re: ascii translator problem
Posted 19 December 2006 - 05:49 PM
Dim strInput As String
Dim intCode As Integer
Dim strNumber(or this letter) As String
Dim intPosition As Integer
For intPosition = 0 to Len(txtInput.Text)
strInput=Mid(txtInput.Text,1)
If strInput = "y" Or "Y" Then
strInput = "A"
ElseIf strInput="z" Or "Z" Then
strInput="B"
Else
strInput=""
Then strInput=""
(Sorry don't get the store stuff)
lblTranslation.Caption=UCase(strInput)
Next intPosition
what about decode please help me out
KeyWiz, on 19 Dec, 2006 - 05:38 PM, said:
Also it is always best to CONVERT a data type tp the type of data you are dealing with.
You can do it all in one line, but it is easier to follow if you break it up.
lblTranslation.Caption=Str(Asc(Ucase(strInput)+2))
Dim myInputChar as String Dim intEncode as Integer Dim strThisLetter as String ' Create a loop to go from the beginning of the text to the end. For intPosition = 0 to Len(txtMessage.text) ' Textbox allows input ' retrieve one single character from within the string myIputChar = Mid(txtMessage.text, intPosition,1) ' put conditional statements here to handle special characters ' and to store the converted value in intEncode ' output the converted character to a label, appending to end lblTranslation.Caption = lblTranslation.Caption & Str(intEncode) ' repeat untill end of txtMessage.text is reached. Next intPosition
Use VB Help and look up ASCII, it will show you the complete list of ASCII codes. 0-127 are considered STANDARD ASCII and codes 128 - 255 are considered EXTENDED ASCII
lokithe2nd, on 19 Dec, 2006 - 05:30 PM, said:
m2s87, on 19 Dec, 2006 - 05:22 PM, said:
Private Sub Text1_Change() Dim tekst_2$ tekst_2 = leia_2(UCase(Text1.Text), arv) Text2.Text = tekst_2 Text3.Text = leia_3(Split(tekst_2, ","), arv) End Sub Function leia_2(tekst_1, ByRef arv) For i = 1 To Len(tekst_1) tekst_2 = tekst_2 & "," & Asc(Mid(tekst_1, i, 1)) arv = arv + 1 Next i leia_2 = Replace(Replace(tekst_2, 89, 65), 90, 66) End Function Function leia_3(a, arv) For i = 1 To arv tekst_3 = tekst_3 & Chr(a(i)) Next i leia_3 = tekst_3 End Function
what does all of that stand for I must be using a different version I use microsoft basic version 5 or 6 what is the tekst? thank you so musch by the way
This is not the intent of this site, when you assist someone, explain to them what you are doing step by step and please do not do the entire work for them, let them learn. We are here to provide ASSISTANCE with UNDERSTANDING not to provide solutions, especially those which are obscure in their implementation.
#6
Re: ascii translator problem
Posted 19 December 2006 - 06:08 PM
If 1 would define the best comment, it would be:
Best comment is the code © that is in relation to the manuscript (m), in way that c/m=1
If (s)he understands the code there is no problem because (s)he would be able to comment it himself or for that matter rewrite it.
If (s)he does not understand the code, there is no problem because, (s)he could not understand it.
No matter which way you take it, it was a ~15 line code made under >10 min. And sometimes the right solution helps to understand the code best
#7
Re: ascii translator problem
Posted 19 December 2006 - 06:15 PM
m2s87, on 19 Dec, 2006 - 06:08 PM, said:
If 1 would define the best comment, it would be:
Best comment is the code © that is in relation to the manuscript (m), in way that c/m=1
If (s)he understands the code there is no problem because (s)he would be able to comment it himself or for that matter rewrite it.
If (s)he does not understand the code, there is no problem because, (s)he could not understand it.
No matter which way you take it, it was a ~15 line code made under >10 min. And sometimes the right solution helps to understand the code best :crazy:
#8
Re: ascii translator problem
Posted 19 December 2006 - 06:31 PM
lokithe2nd, on 19 Dec, 2006 - 06:15 PM, said:
It was a clarification to i provided a code solution. This code is written in VB 6 classic, and you need a form and 3 textboxes in it, named (Text1,Text2,Text3). When you change the text in the first textbox then the values will be evaluated to then textbox 2 and 3. This should work in VB 5, VBA. By the way "tekst" in english is "text" and "leia" is "find"
#9
Re: ascii translator problem
Posted 19 December 2006 - 06:49 PM
m2s87, on 19 Dec, 2006 - 06:31 PM, said:
lokithe2nd, on 19 Dec, 2006 - 06:15 PM, said:
It was a clarification to i provided a code solution. This code is written in VB 6 classic, and you need a form and 3 textboxes in it, named (Text1,Text2,Text3). When you change the text in the first textbox then the values will be evaluated to then textbox 2 and 3. This should work in VB 5, VBA. By the way "tekst" in english is "text" and "leia" is "find"
#10
Re: ascii translator problem
Posted 19 December 2006 - 08:25 PM
#11
Re: ascii translator problem
Posted 20 December 2006 - 06:16 AM
i guess I'll just fail
#12
Re: ascii translator problem
Posted 20 December 2006 - 11:14 AM
m2s87, on 19 Dec, 2006 - 06:08 PM, said:
If 1 would define the best comment, it would be:
Best comment is the code © that is in relation to the manuscript (m), in way that c/m=1
If (s)he understands the code there is no problem because (s)he would be able to comment it himself or for that matter rewrite it.
If (s)he does not understand the code, there is no problem because, (s)he could not understand it.
No matter which way you take it, it was a ~15 line code made under >10 min. And sometimes the right solution helps to understand the code best
I think the problem here is that YOU understand exactly what you are doing, BUT the person you are attempting to help has NO CLUE at all. Therefore, no, the code is not obvious. This is why we use COMMENTS in our code and when you are introducing a more advanced method of data handling, you are preventing the person requiring help from even learning the BASICS of programming, in fact I would guess that your code solution added to the confusion. When dealing with unexperienced people you MUST use simple programming methods. One step at a time. The length of code has nothing to do with complexity.
To determine the ASCII code of a character use ASC(myCharacter)
To remove one character from a string use the MID(x$,y,z), where x$ is a STRING of Characters to be encoded, myCharacter = MID(x$, position, length)
If a string of Characters contains 8 letters and spaces, MID() allows you to START at a POSITION in the string, and choose the LENGTH of the substring you are looking for, in this case LENGTH = 1 to retrieve 1 Character at Position in String x$ with a LENGTH of 1 Character.
example:
x$ = "This word"
Mid(x$,0,1) = "T"
Mid(x$,1,1) = "h"
Mid(x$,2,1) = "i"
etc.
If you needed to retrieve more letters at once, you can by changing the LENGTH value.
example:
x$ = "This word"
Mid(x$,0,2) = "Th"
Mid(x$,1,2) = "hi"
Mid(x$,2,2) = "is"
etc.
Once you know the ASCII code of a character you can alter it by adding 2 to the value and the converting that new value to a Character by using Chr(n) where n = your converted code.
oneLetter = Mid(x$,Postion,Length)
oneLetterCode = ASC(oneLetter)
myEncodedCharacter = Chr(oneLetterCode + 2)
To decode you would use the same processes, except the New Conversion will be subtracting 2 from the Encoded Character.
myUnEncodedCharacter = Chr(oneLetterCode - 2)
|
|

New Topic/Question
Reply




MultiQuote





|