QUOTE(Bobulous @ 23 Nov, 2006 - 08:52 AM)

Ok so I'm making a program that converts a word into piglatin, and I'm having huge troubles in making it work. As it is right now, it will convert words that start with vowels properly, but when I input a word that starts with a consonant, I have an error.
text1 is the input box,
text2 is an invisible box,
text3 is the results box
CODE
Private Sub Command1_Click()
Text3.Text = ""
Text2.Text = ""
If Left(Text1.Text, 1) = "A" Or Left(Text1.Text, 1) = "E", etc.
Text3.Text = Text1.Text + "ay"
Exit Sub
End If
While Left(Text1.Text, 1) <> "A" Or Left(Text1.Text, 1) <> "E", etc.
Text2.Text = Text2.Text + Left(Text1.Text, 1)
Text1.Text = Right(Text1.Text, (Len(Text1.Text) - 1))
Text3.Text = Text2.Text + "ay"
Wend
End Sub
What you are doing in your While - Wend is simply stripping the characters off one at a time untill there is nothing left. Use AND instead of OR.
also when you are repeating the same function again and again, use a variable.
try this
CODE
dim myVar as string
myVar = LCASE(LEFT(text1text,1))
' this will check for leading vowels, if the letter is not a vowel then the procedure will continue.
WHILE myVar <> "a" AND myVar <> "e" AND myVar <> "i" AND myVar <> "o" AND myVar <> "u" AND myVar <> "y"
' by using OR every letter is NOT an A or NOT an E, etc.
'your code here
WEND
This post has been edited by KeyWiz: 23 Nov, 2006 - 08:35 AM