ascii translator problem

i don't even know where to start my teacher just skipped everythin

Page 1 of 1

11 Replies - 6164 Views - Last Post: 20 December 2006 - 11:14 AM Rate Topic: -----

#1 lokithe2nd  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 19-December 06

ascii translator problem

Posted 19 December 2006 - 04:22 PM

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

Is This A Good Question/Topic? 0
  • +

Replies To: ascii translator problem

#2 m2s87  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 21
  • View blog
  • Posts: 390
  • Joined: 28-November 06

Re: ascii translator problem

Posted 19 December 2006 - 05:22 PM

Well, i guess you wanted something like that:

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

Was This Post Helpful? 0
  • +
  • -

#3 lokithe2nd  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 19-December 06

Re: ascii translator problem

Posted 19 December 2006 - 05:30 PM

View Postm2s87, on 19 Dec, 2006 - 05:22 PM, said:

Well, i guess you wanted something like that:

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
Was This Post Helpful? 0
  • +
  • -

#4 KeyWiz  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 8
  • View blog
  • Posts: 438
  • Joined: 26-October 06

Re: ascii translator problem

Posted 19 December 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 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

View Postlokithe2nd, on 19 Dec, 2006 - 05:30 PM, said:

View Postm2s87, on 19 Dec, 2006 - 05:22 PM, said:

Well, i guess you wanted something like that:

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

Was This Post Helpful? 0
  • +
  • -

#5 lokithe2nd  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 19-December 06

Re: ascii translator problem

Posted 19 December 2006 - 05:49 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





View PostKeyWiz, on 19 Dec, 2006 - 05:38 PM, said:

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))

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

View Postlokithe2nd, on 19 Dec, 2006 - 05:30 PM, said:

View Postm2s87, on 19 Dec, 2006 - 05:22 PM, said:

Well, i guess you wanted something like that:

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.

Was This Post Helpful? 0
  • +
  • -

#6 m2s87  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 21
  • View blog
  • Posts: 390
  • Joined: 28-November 06

Re: ascii translator problem

Posted 19 December 2006 - 06:08 PM

Is'nt the code obivous?

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:
Was This Post Helpful? 0
  • +
  • -

#7 lokithe2nd  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 19-December 06

Re: ascii translator problem

Posted 19 December 2006 - 06:15 PM

well could you tell me what all that meant btw i think we're using different visual basics

View Postm2s87, on 19 Dec, 2006 - 06:08 PM, said:

Is'nt the code obivous?

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:

Was This Post Helpful? 0
  • +
  • -

#8 m2s87  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 21
  • View blog
  • Posts: 390
  • Joined: 28-November 06

Re: ascii translator problem

Posted 19 December 2006 - 06:31 PM

View Postlokithe2nd, on 19 Dec, 2006 - 06:15 PM, said:

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" :D
Was This Post Helpful? 0
  • +
  • -

#9 lokithe2nd  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 19-December 06

Re: ascii translator problem

Posted 19 December 2006 - 06:49 PM

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

View Postm2s87, on 19 Dec, 2006 - 06:31 PM, said:

View Postlokithe2nd, on 19 Dec, 2006 - 06:15 PM, said:

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" :D

Was This Post Helpful? 0
  • +
  • -

#10 lokithe2nd  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 19-December 06

Re: ascii translator problem

Posted 19 December 2006 - 08:25 PM

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.
Was This Post Helpful? 0
  • +
  • -

#11 lokithe2nd  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 19-December 06

Re: ascii translator problem

Posted 20 December 2006 - 06:16 AM

thank you to those who tryed to help me but I still don't get it.
i guess I'll just fail :(
Was This Post Helpful? 0
  • +
  • -

#12 KeyWiz  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 8
  • View blog
  • Posts: 438
  • Joined: 26-October 06

Re: ascii translator problem

Posted 20 December 2006 - 11:14 AM

View Postm2s87, on 19 Dec, 2006 - 06:08 PM, said:

Is'nt the code obivous?

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:


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)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1