Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace Vowel_Counter
- {
- public partial class frmVowelCounter : Form
- {
- public frmVowelCounter()
- {
- InitializeComponent();
- }
- private void btnCount_Click(object sender, EventArgs b)
- {
- string text = txtText.Text;
- int my_count = 0;
- foreach (char ch_vowel in text)
- {
- switch (ch_vowel)
- {
- case 'a':
- case 'A':
- my_count++;
- break;
- case 'e':
- case 'E':
- my_count++;
- break;
- case 'i':
- case 'I':
- my_count++;
- break;
- case 'o':
- case 'O':
- my_count++;
- break;
- case 'u':
- case 'U':
- my_count++;
- break;
- default:
- break;
- }
- }
- if (text == "")
- {
- MessageBox.Show("There are 0 vowels. Please enter some text.");
- }
- else
- {
- MessageBox.Show("The number of vowels in " + text + " is " + my_count);
- }
- }
- private void btnExit_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- }
- }
Add Comment
Please, Sign In to add comment