Translating English to Pig Latin

Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Oct 2007
Posts: 89
Reputation: leroi green is an unknown quantity at this point 
Solved Threads: 0
leroi green leroi green is offline Offline
Junior Poster in Training

Translating English to Pig Latin

 
0
  #1
May 4th, 2008
Hey all,

I've got this program where I have to translate a word from English to Pig Latin. I'm sorta on the brink but I'm missing something.

the test words are "ant" and "chair" but they should then turn to "ant-WAY" and "air-chay"

but i'm ending up with "ant-anAY" and "air-ChAY"

and even further I know that I'm kinda cheating on the chair translation because it definitely won't work with any other word that doesn't start with a vowel. Finally is someone enters a numeric value like 56 it should show "56-WAY".

I'm stuck...any help? Code below




  1. Private Sub xTranslateButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xTranslateButton.Click
  2.  
  3. Dim strInput As String
  4. Dim str1stCharacter As String
  5. Dim strOutput As String
  6. Dim intStringLength As Integer
  7.  
  8. strInput = Me.xEnterText.Text
  9.  
  10. str1stCharacter = Microsoft.VisualBasic.Left(strInput, 1)
  11.  
  12. If str1stCharacter = "A" Or str1stCharacter = "E" _
  13. Or str1stCharacter = "I" Or str1stCharacter = "O" _
  14. Or str1stCharacter = "U" Or str1stCharacter = "Y" Then
  15.  
  16. strOutput = strInput & "-WAY"
  17. Else
  18. intStringLength = Len(strInput)
  19. strOutput = Microsoft.VisualBasic.Right(strInput, 3) _
  20. & "-" & Microsoft.VisualBasic.Left(strInput, 2) & "AY"
  21. End If
  22. Me.xAnswerLabel.Text = "The Pig Latin Translation of " & strInput & " is " & strOutput & "."
  23. End Sub
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 89
Reputation: leroi green is an unknown quantity at this point 
Solved Threads: 0
leroi green leroi green is offline Offline
Junior Poster in Training

Re: Translating English to Pig Latin

 
0
  #2
May 4th, 2008
okay, i've got the first part working but I've still got problems with the second part outlining words that start with cons.

here's the new code.

  1. Private Sub xTranslateButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xTranslateButton.Click
  2.  
  3. Dim strInput As String
  4. Dim str1stCharacter As String
  5. Dim strOutput As String
  6. Dim intStringLength As Integer
  7.  
  8. strInput = Me.xEnterText.Text
  9.  
  10. str1stCharacter = Microsoft.VisualBasic.Left(strInput, 1)
  11.  
  12. If str1stCharacter = "A" Or str1stCharacter = "E" _
  13. Or str1stCharacter = "I" Or str1stCharacter = "O" _
  14. Or str1stCharacter = "U" Or str1stCharacter = "Y" _
  15. Or str1stCharacter = "1" Or "2" Or "3" Or "4" Or "5" Or "6" Or "7" Or "8" Or "9" Or "0" Then
  16.  
  17. strOutput = strInput & "-WAY"
  18. ElseIf str1stCharacter = "Q" Or "W" Or "R" Or "T" Or "P" Or "S" _
  19. Or "D" Or "F" Or "G" Or "H" Or "J" Or "K" Or "L" Or "Z" _
  20. Or "X" Or "C" Or "V" Or "B" Or "N" Or "M" Then
  21. intStringLength = Len(strInput)
  22. strOutput = Microsoft.VisualBasic.Right(strInput, 3) _
  23. & "-" & Microsoft.VisualBasic.Left(strInput, 2) & "AY"
  24. End If
  25. Me.xAnswerLabel.Text = "The Pig Latin Translation of " & strInput & " is " & strOutput & "."
  26. End Sub
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 25
Reputation: poguemahone is an unknown quantity at this point 
Solved Threads: 2
poguemahone's Avatar
poguemahone poguemahone is offline Offline
Light Poster

Re: Translating English to Pig Latin

 
1
  #3
May 4th, 2008
Try this:
<code>
Dim strInput As String = ""
Dim str1stCharacter As String = ""
Dim strOutput As String = ""
Dim intStringLength As Integer = 0

strInput = Me.xEnterText.Text

str1stCharacter = Microsoft.VisualBasic.Left(strInput, 1)
Select Case str1stCharacter
Case "A", "E", "I", "O", "U", "Y", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
strOutput = strInput & "-WAY"
Case Else
intStringLength = Len(strInput)
strOutput = Microsoft.VisualBasic.Right(strInput, 3) _
& "-" & Microsoft.VisualBasic.Left(strInput, 2) & "AY"
End Select
Me.xAnswerLabel.Text = "The Pig Latin Translation of " & strInput & " is " & strOutput & "."
Exit Sub
</code>

Good Luck!
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 89
Reputation: leroi green is an unknown quantity at this point 
Solved Threads: 0
leroi green leroi green is offline Offline
Junior Poster in Training

Re: Translating English to Pig Latin

 
0
  #4
May 4th, 2008
cool, working except with the word "ant" to "ant-way"
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 25
Reputation: poguemahone is an unknown quantity at this point 
Solved Threads: 2
poguemahone's Avatar
poguemahone poguemahone is offline Offline
Light Poster

Re: Translating English to Pig Latin

 
0
  #5
May 4th, 2008
In the Select Case, change str1stCharacter to str1stCharacter.ToUpper.

Select Case str1stCharacter.ToUpper()
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC