Tuesday, January 26, 2010

C# Class 1/25/10

We continue talking about the array. Instead of holding values in a database, we stored them in an array. Our array had seven elements. So referencing will be 0, 1, 2, 3, 4, 5, and 6. So to display that data being held in the array, I had to reference it location. Here is the code.



private void button1_Click(object sender, EventArgs e)
{
string[] value2 = new string[7];
int[] value3= new int[2];
int zip;
//int ph;
value2[0] = textBox1.Text; //fname
value2[1] = textBox2.Text; //lname
value2[2] = textBox3.Text; //address
value2[3] = textBox4.Text; //city
value2[4] = textBox5.Text; //state
value2[5] = textBox7.Text; //phone

zip = Convert.ToInt32(textBox6.Text); //zip

value3[0] = zip; //equal textbox6.text

label15.Text = value2[0];// fname
label16.Text = value2[1];// lname
label17.Text = value2[2];// address
label18.Text = value2[3];// city
label19.Text = value2[4];// state
label20.Text = Convert.ToString(value3[0]);// zip
label21.Text = value2[5];//phone
}

private void Form1_Load(object sender, EventArgs e)
{

}

private void button3_Click(object sender, EventArgs e)
{
textBox1.Text = ""; //fname
textBox2.Text = ""; //lname
textBox3.Text = ""; //address
textBox4.Text = ""; //city
textBox5.Text = ""; //state
textBox6.Text = ""; //zip
textBox7.Text = ""; //phone

label15.Text = ""; //fname
label16.Text = ""; //lname
label17.Text = ""; //address
label18.Text = ""; //city
label19.Text = ""; //state
label20.Text = ""; //zip
label21.Text = ""; //phone
}

private void button2_Click(object sender, EventArgs e)
{
this.Close();
}

No comments:

Post a Comment