Join 137,261 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,525 people online right now. Registration is fast and FREE... Join Now!
i'm not trying to cheat alright i just need someone to explain this to me and help. i need to make an application that allow the user to type in something and come out in code by converting each letter in the original message to its corresponding ASCII code number, add two to the code number, and then convert it back to characters to produce the message. Y and Z are supposed to converted to A and B and the spaces are supposed to be the same and all the code has to be in uppercase whether the user types in lowercase or uppercase. please don't just give me the answer i need to know how to do this for the future here is what I have so far under the command button that puts the text into code>[Dim strTemp As String 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
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 Dec, 2006 - 04:32 PM
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
You need to move the Addition outside of the ACS() convertion. 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))
CODE
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
QUOTE(lokithe2nd @ 19 Dec, 2006 - 05:30 PM)
QUOTE(m2s87 @ 19 Dec, 2006 - 05:22 PM)
Well, i guess you wanted something like that:
CODE
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 Dec, 2006 - 04:41 PM
so i would do 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
QUOTE(KeyWiz @ 19 Dec, 2006 - 05:38 PM)
You need to move the Addition outside of the ACS() convertion. 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))
CODE
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
QUOTE(lokithe2nd @ 19 Dec, 2006 - 05:30 PM)
QUOTE(m2s87 @ 19 Dec, 2006 - 05:22 PM)
Well, i guess you wanted something like that:
CODE
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.
well could you tell me what all that meant btw i think we're using different visual basics
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"
could you please email me at yahoo and explain it more in depth because i need to have only one text box i label and 2 command buttons not including done of course. i know its alot of trouble but please help me my email is lokithe3rd@yahoo.com
QUOTE(m2s87 @ 19 Dec, 2006 - 06:31 PM)
QUOTE(lokithe2nd @ 19 Dec, 2006 - 06:15 PM)
well could you tell me what all that meant btw i think we're using different visual basics
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"
please....help me I will fail my whole class if someone doesn't help me i know it isn't your problem but my teacher skipped 3 chapters and I can't fail because of that please please please email me IM me whatever i just need and explanation.
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.
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.