-
April 11th, 2015, 07:49 PM
#1
can someone help me with my pig latin converter?
I have been working on a pig latin converter. If a letter starts with a vowel or number it should end with way if it begins with a consonant it should revert the letters so the first one begins with aeiouy like chair should be airchay. Everything in my program works but can someone tell me why im getting aircay instead of airchay?
'determine if the word starts with a vowel, consonant, or numeric
'display original word with vowel as piglatin word add "-way" to end of word
'consonants to end of word with 'ay" added to end of consonants
'if words are numeric add "-way" to end of numeric expression
If strOriginalWord.Substring(0, 1).ToUpper() Like "[AEIOU]" Then
strPigLatin = strOriginalWord & "-way"
lblConvertedword.Text = strPigLatin
ElseIf strOriginalWord.Substring(0, 1) Like "[0-9]" Then
strPigLatin = strOriginalWord & "-way"
lblConvertedword.Text = strPigLatin
Else
strPigLatin = Mid(strOriginalWord, 3) & Mid(strOriginalWord, 1, 1) & "-ay"
lblConvertedword.Text = strPigLatin
End If
txtWordenter.Focus()
End Sub
Private Sub ConvertPigLatin(ByVal wordConvert As String, ByRef pigLatinWord As String)
If wordConvert.Substring(0, 1).ToUpper Like "[AEIOU]" Then
pigLatinWord = wordConvert & "way"
End If
Dim strTemp As String = ""
If wordConvert.Substring(0, 1).ToUpper Like "[!AEIOU]" Then
Do While wordConvert <> ""
strTemp = strTemp + wordConvert(0)
wordConvert = wordConvert.Remove(0, 1)
If wordConvert.ToUpper Like "[AEIOUY]*" Then
pigLatinWord = wordConvert & strTemp & "ay"
Exit Sub
End If
Loop
End If
If strTemp.ToUpper Like "*[!AEIOUY]*" Then
pigLatinWord = strTemp & "way"""
End If
End Sub
-
April 12th, 2015, 12:18 AM
#2
Re: can someone help me with my pig latin converter?
Please use code tags around blocks of code
[code]Your lines of code here [/code]
and include proper indentation for readability
Always use [code][/code] tags when posting code.
-
April 12th, 2015, 12:03 PM
#3
Re: can someone help me with my pig latin converter?
I fixed it
Code:
Private Sub btnConvert_Click(sender As Object, e As EventArgs) Handles btnConvert.Click
'declare variables
Dim strOriginalWord As String
Dim strPigLatin As String
'assign user input to variable
strOriginalWord = txtWordenter.Text.Trim
' make sure the user enters a word
If strOriginalWord = "" Then
MessageBox.Show("Please Enter a Word")
End If
If strOriginalWord <> Nothing Then
End If
'determine if the word starts with a vowel, consonant, or numeric
'display original word with vowel as piglatin word add "-way" to end of word
'consonants to end of word with 'ay" added to end of consonants
'if words are numeric add "-way" to end of numeric expression
If strOriginalWord.Substring(0, 1).ToUpper() Like "[AEIOU]" Then
strPigLatin = strOriginalWord & "-way"
lblConvertedword.Text = strPigLatin
ElseIf strOriginalWord.Substring(0, 1) Like "[0-9]" Then
strPigLatin = strOriginalWord & "-way"
lblConvertedword.Text = strPigLatin
Else
strPigLatin = Mid(strOriginalWord, 3) & Mid(strOriginalWord, 1, 2) & "-ay"
lblConvertedword.Text = strPigLatin
End If
txtWordenter.Focus()
End Sub
Private Sub ConvertPigLatin(ByVal wordConvert As String, ByRef pigLatinWord As String)
If wordConvert.Substring(0, 1).ToUpper Like "[AEIOU]" Then
pigLatinWord = wordConvert & "way"
End If
Dim strTemp As String = ""
If wordConvert.Substring(0, 1).ToUpper Like "[!AEIOU]" Then
Do While wordConvert <> ""
strTemp = strTemp + wordConvert(0)
wordConvert = wordConvert.Remove(0, 1)
If wordConvert.ToUpper Like "[AEIOUY]*" Then
pigLatinWord = wordConvert & strTemp & "ay"
Exit Sub
End If
Loop
End If
If strTemp.ToUpper Like "*[!AEIOUY]*" Then
pigLatinWord = strTemp & "way"""
End If
End Sub
' make sure the guest wants to leave the app
Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
Dim dlgButton As DialogResult
dlgButton = MessageBox.Show("Do You want To exit ? ", "Cable Direct", MessageBoxButtons.YesNo)
If dlgButton = Windows.Forms.DialogResult.No Then
e.Cancel = True
End If
End Sub
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
Me.Close()
End Sub
'Clears labels when words change
Private Sub ClearLabels(sender As Object, e As EventArgs) Handles txtWordenter.TextChanged
lblConvertedword.Text = String.Empty
End Sub
Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
' clears the words enetered
txtWordenter.Text = String.Empty
End Sub
Private Sub WordConvert_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
End Class
-
April 12th, 2015, 12:04 PM
#4
Re: can someone help me with my pig latin converter?
also sorry I couldn't find the code tags I tried to type code around it myself
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|