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

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

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.

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!

cool, working except with the word "ant" to "ant-way"

In the Select Case, change str1stCharacter to str1stCharacter.ToUpper.

Select Case str1stCharacter.ToUpper()

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.