Hello everyone,
I have to create pig latin game which I did and it is working. The problem is I coded it so it can translate one word. I need to know how can I make it translate a sentence that I don't know how many words in it.
Here is my code for the one word translation:
Public Class Form1
Private Sub Convert_to_Pig_Latin(ByVal strWordToConvert As String, ByRef strPigLatinWord As String)
If strWordToConvert.Substring(0, 1).ToUpper Like "[AEIOU]" Then
strPigLatinWord = strWordToConvert & "-way"
End If
Dim strTemp As String = ""
If strWordToConvert.Substring(0, 1).ToUpper Like "[!AEIOU]" Then
Do While strWordToConvert <> ""
strTemp = strTemp + strWordToConvert(0)
strWordToConvert = strWordToConvert.Remove(0, 1)
If strWordToConvert.ToUpper Like "[AEIOUY]*" Then
strPigLatinWord = strWordToConvert & "-" & strTemp & "ay"
Exit Sub
End If
Loop
End If
If strTemp.ToUpper Like "*[!AEIOUY]*" Then
strPigLatinWord = strTemp & "-way"
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strOriginalWord As String
Dim strPigLatin As String
strOriginalWord = TextBox1.Text.Trim
Call Convert_to_Pig_Latin(strOriginalWord, strPigLatin)
Label1.Text = strPigLatin
End Sub
End Class
Thank you
Regards