473,386 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

can anyone give me help on my pig latin converter?

I am making a program for a pig latin converter.I have to use a function. if the word begins with a vowel add -way at the end if it does not begin with a vowel then add a dash to the end of the word until the first letter in the word is aeiouy then add ay to the end like chair would be air-chay. as of now all of my words are ending in way when I push my convert button


Expand|Select|Wrap|Line Numbers
  1.  Private Sub btnConvert_Click(sender As Object, e As EventArgs) Handles btnConvert.Click
  2.         ' declare the variables
  3.         Dim strWord As String
  4.  
  5.         'trim the input
  6.         strWord = txtWordenter.Text.Trim
  7.  
  8.         If strWord = "" Then
  9.  
  10.             MessageBox.Show("Please Enter a Word")
  11.  
  12.         End If
  13.  
  14.  
  15.  
  16.         If strWord <> Nothing Then
  17.  
  18.         End If
  19.  
  20.  
  21.         ' if input begins with a vowel
  22.         If strWord.ToString Like "[aeiou]*" Then
  23.             Call Convert_To_Pig(strWord)
  24.  
  25.         Else
  26.             ' if input begins with nonvowel
  27.             Call insertAy(strWord)
  28.         End If
  29.  
  30.         ' send focus to input
  31.         txtWordenter.SelectAll()
  32.  
  33.     End Sub
  34.  
  35.     Private Sub Convert_To_Pig(ByVal convertWord As String)
  36.         'function will put -way to words that  have vowels
  37.         Const Vowel As String = "-way"
  38.         txtConvertedword.Text = convertWord & Vowel
  39.  
  40.  
  41.     End Sub
  42.  
  43.     Private Sub insertAy(ByRef word As String)
  44.         ' sees if word contains nonvowels
  45.         Dim remainder As String = ""
  46.         Do Until word = ""
  47.             remainder += word(0)
  48.             word = word.Remove(0, 1)
  49.  
  50.             'if nonvowel is found
  51.             If word.ToLower Like "[aeiouy]* " Then
  52.                 txtConvertedword.Text = remainder & "-" & remainder & "-ay"
  53.                 Exit Sub
  54.  
  55.             End If
  56.         Loop
  57.         Call Convert_To_Pig(remainder)
  58.     End Sub
Apr 4 '15 #1
1 1782
Seth Schrock
2,965 Expert 2GB
You don't say what is going wrong. However, there were a few things that I noticed in your code that could have been giving you problems so I have fixed those in the code below.
Expand|Select|Wrap|Line Numbers
  1.  Private Sub btnConvert_Click(sender As Object, e As EventArgs) Handles btnConvert.Click
  2.     ' declare the variables
  3.     Dim strWord As String
  4.  
  5.     'trim the input
  6.     strWord = txtWordenter.Text.Trim
  7.  
  8.     If strWord = "" Then
  9.  
  10.         MessageBox.Show("Please Enter a Word")
  11.  
  12.     Else
  13.         ' if input begins with a vowel
  14.         Select Case strWord.SubString(0, 1).ToUpper
  15.             Case "A", "E", "I", "O", "U"
  16.                 Call Convert_To_Pig(strWord)
  17.  
  18.             Else 'Nonvowel
  19.                 Call insertAy(strWord)
  20.         End If
  21.  
  22.         ' send focus to input
  23.         txtWordenter.SelectAll()
  24.  
  25.     End If
  26.  
  27.  
  28. End Sub
Jun 5 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: RT | last post by:
I have followed the step by step instructions in the login manual Created login page Use LSC01 This works - login and get redirected to the proper page My problem is the cookie variables...
6
by: Kartik | last post by:
Hello, I was trying to develop a game in c++ ( text mode ), but I couldn't figure out how to make rest of the elements moving in the game while waiting for the player's input, or, how to accept...
1
by: Prafull Soni | last post by:
hi Can anyone give me program to find difference between two dates? thanks Prafull Soni
8
by: CM | last post by:
Hi, Could anyone please help me? I am completing my Master's Degree and need to reproduce a Webpage in Word. Aspects of the page are lost and some of the text goes. I would really appreciate it....
3
by: MaStA | last post by:
I have to build a pig latin converter. It isn't an in depth one that needs to care about vowels, punctuation, etc. All it has to do is simply receive a sentence, break up the words, move the first...
2
by: kang jia | last post by:
hi i am very new to python, and my final year project requires me to use Django framework to do application. Although now i understand their logic and some simple application exercise, yet how...
0
by: ajweber | last post by:
Hi, I'm new to XML coding and I've got a problem I need help with. I'm developing a model in .gmax for FSX and I'm attempting to trigger animated objects using a switch that determines which...
0
by: Vikram Raman | last post by:
Hi I want to remove all overlays from the google map. I removed all markers but i am not able to remove polylines. Can anyone give me example to remove the polyline from the map? I am using google...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.