Click here to Skip to main content
15,914,924 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
can any one help me with a code for displaying vowels from a text entered in a textbox and text should be displayed in a lable ..
i used tab control for placing textbox and lable i place textbox in one tab and lable in another..

Ex if the text entered in text box is David
then if i click lable in another tab a msg should be displayed inside the lable Vowels are : a,i
plz help me with the code
Posted
Comments
BillWoodruff 24-Sep-13 5:47am    
What you are describing is so easy to program: what have you tried so far ?

The idea of having text-entry on one TabPage analyzed for vowels, and then the vowels shown on a click on a Label on another TabPage is very strange. What are your goals here; why are you using TabPages ?

use keypress event for textbox to update the label.
 
Share this answer
 
Write this method on your .cs page

C#
public static string ExtractVowels(string text)
{
    // Note that this won't find upper-case vowels...
    var vowelArray = text.Where(c => "aeiou".Contains(c))
                         .ToArray();
    // Upper-case it if you want, of course.
    return new string(vowelArray);
}

call this method on Button click
C#
label1.Text=ExtractVowels(textbox1.text);


Thanks & Regard
Sham :)
 
Share this answer
 
C#
Char[] vowels = new char[] { 'a', 'e', 'i', 'o', 'u' };
            string str = textBox1.Text;
            string result = "";
            string r = "";
            char[] ch = str.ToCharArray();
            foreach (char c in ch)
            {
                if (vowels.Contains(c))
                {
                    result = c.ToString();
                    r = r + result;
                }

                else
                {
                    //consonant
                }
                label2.Text = radioButton2.Text + textBox1.Text + "Length is:" + textBox1.TextLength + "Vowels are : " + r;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900