using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace WindowsApplication4
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button Go1;
private System.Windows.Forms.Button Go2;
private System.Windows.Forms.Label L1;
private System.Windows.Forms.Label L2;
private System.Windows.Forms.TextBox TB1;
private System.Windows.Forms.TextBox TB2;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Go1 = new System.Windows.Forms.Button();
this.L1 = new System.Windows.Forms.Label();
this.L2 = new System.Windows.Forms.Label();
this.Go2 = new System.Windows.Forms.Button();
this.TB1 = new System.Windows.Forms.TextBox();
this.TB2 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// Go1
//
this.Go1.Location = new System.Drawing.Point(64, 56);
this.Go1.Name = "Go1";
this.Go1.Size = new System.Drawing.Size(96, 24);
this.Go1.TabIndex = 0;
this.Go1.Text = "Go1";
this.Go1.Click += new System.EventHandler(this.Go1_Click);
//
// L1
//
this.L1.BackColor = System.Drawing.Color.White;
this.L1.Location = new System.Drawing.Point(13, 0);
this.L1.Name = "L1";
this.L1.Size = new System.Drawing.Size(294, 48);
this.L1.TabIndex = 1;
this.L1.Text = "L1";
this.L1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// L2
//
this.L2.BackColor = System.Drawing.Color.White;
this.L2.Location = new System.Drawing.Point(16, 88);
this.L2.Name = "L2";
this.L2.Size = new System.Drawing.Size(288, 56);
this.L2.TabIndex = 2;
this.L2.Text = "L2";
this.L2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// Go2
//
this.Go2.Location = new System.Drawing.Point(160, 56);
this.Go2.Name = "Go2";
this.Go2.Size = new System.Drawing.Size(96, 24);
this.Go2.TabIndex = 3;
this.Go2.Text = "Go2";
this.Go2.Click += new System.EventHandler(this.Go2_Click);
//
// TB1
//
this.TB1.Location = new System.Drawing.Point(0, 56);
this.TB1.Name = "TB1";
this.TB1.Size = new System.Drawing.Size(56, 20);
this.TB1.TabIndex = 4;
this.TB1.Text = "textBox1";
this.TB1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// TB2
//
this.TB2.Location = new System.Drawing.Point(264, 56);
this.TB2.Name = "TB2";
this.TB2.Size = new System.Drawing.Size(56, 20);
this.TB2.TabIndex = 5;
this.TB2.Text = "textBox2";
this.TB2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackColor = System.Drawing.SystemColors.ControlLight;
this.ClientSize = new System.Drawing.Size(320, 142);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.TB2,
this.TB1,
this.Go2,
this.L2,
this.L1,
this.Go1});
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
}
int ac=0, bc=0, cc=0;
private void Go1_Click(object sender, System.EventArgs e)
{
L1.Text=""; L2.Text="";
if(TB1.Text == "a"||TB1.Text == "b"||TB1.Text == "c")
{
char letter = char.Parse(TB1.Text);
switch (letter)
{
case 'a': ++ac; L1.Text+="a: "+ ac; break;
case 'b': ++bc; L1.Text+="b: "+ bc; break;
case 'c': ++cc; L1.Text+="c: "+ cc; break;
}
}
else
{
MessageBox.Show("Incorrect letter entered. Lowercase letters only");
Cursor.Position = new System.Drawing.Point(493,430);}
}
public void count(int a, int b, int c)
{
L1.Text+="Totals for each letter:";
L2.Text+="a: "+ a+ "\nb: "+ b+ "\nc: "+ c;
}
private void Go2_Click(object sender, System.EventArgs e)
{
TB1.SelectAll();
L1.Text=""; L2.Text="";
count(ac, bc, cc);
}
}
}