| | |
Translating English to Pig Latin
Please support our VB.NET advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Oct 2007
Posts: 89
Reputation:
Solved Threads: 0
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
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
VB.NET Syntax (Toggle Plain Text)
Private Sub xTranslateButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xTranslateButton.Click Dim strInput As String Dim str1stCharacter As String Dim strOutput As String Dim intStringLength As Integer strInput = Me.xEnterText.Text str1stCharacter = Microsoft.VisualBasic.Left(strInput, 1) If str1stCharacter = "A" Or str1stCharacter = "E" _ Or str1stCharacter = "I" Or str1stCharacter = "O" _ Or str1stCharacter = "U" Or str1stCharacter = "Y" Then strOutput = strInput & "-WAY" Else intStringLength = Len(strInput) strOutput = Microsoft.VisualBasic.Right(strInput, 3) _ & "-" & Microsoft.VisualBasic.Left(strInput, 2) & "AY" End If Me.xAnswerLabel.Text = "The Pig Latin Translation of " & strInput & " is " & strOutput & "." End Sub
•
•
Join Date: Oct 2007
Posts: 89
Reputation:
Solved Threads: 0
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.
here's the new code.
VB.NET Syntax (Toggle Plain Text)
Private Sub xTranslateButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xTranslateButton.Click Dim strInput As String Dim str1stCharacter As String Dim strOutput As String Dim intStringLength As Integer strInput = Me.xEnterText.Text str1stCharacter = Microsoft.VisualBasic.Left(strInput, 1) If str1stCharacter = "A" Or str1stCharacter = "E" _ Or str1stCharacter = "I" Or str1stCharacter = "O" _ Or str1stCharacter = "U" Or str1stCharacter = "Y" _ Or str1stCharacter = "1" Or "2" Or "3" Or "4" Or "5" Or "6" Or "7" Or "8" Or "9" Or "0" Then strOutput = strInput & "-WAY" ElseIf str1stCharacter = "Q" Or "W" Or "R" Or "T" Or "P" Or "S" _ Or "D" Or "F" Or "G" Or "H" Or "J" Or "K" Or "L" Or "Z" _ Or "X" Or "C" Or "V" Or "B" Or "N" Or "M" Then intStringLength = Len(strInput) strOutput = Microsoft.VisualBasic.Right(strInput, 3) _ & "-" & Microsoft.VisualBasic.Left(strInput, 2) & "AY" End If Me.xAnswerLabel.Text = "The Pig Latin Translation of " & strInput & " is " & strOutput & "." End Sub
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!
<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!
![]() |
Other Threads in the VB.NET Forum
- Previous Thread: Class Library In VS 2003
- Next Thread: MDI form
Views: 1841 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
"crystal .net .net2005 30minutes 2008 access add application array assignment basic binary box button buttons center code connectionstring convert cpu data database databasesearch datagrid datagridview design designer dissertation dissertations dissertationthesis dll dosconsolevb.net editvb.net employees error excel exists firewall folder function image images isnumericfuntioncall listview login math memory mobile module msaccess mssqlbackend mysql navigate net opacity page pan peertopeervideostreaming picturebox plugin port print printing printpreview problem record refresh reports" reuse save savedialog search serial sorting sql sqldatbase storedprocedure string structures studio temp textbox timer upload useraccounts usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet vista visual visualbasic visualbasic.net visualstudio2008 web wpf xml





