Yesterday we went over arrays again and I was able to get a little bit more of an understanding of the concept and how to apply it. Here I am posting a code to a program we had to develop using array's. I hope that I have the concept down.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//here the arrays are and elements are established
string[] values2 = new string[7];
int[] values = new int[2];
int zipcode;
//here the elements are assigned a textbox
values2[0] = textBox1.Text;
values2[1] = textBox2.Text;
values2[2] = textBox3.Text;
values2[3] = textBox4.Text;
values2[4] = textBox5.Text;
values2[5] = textBox7.Text;
zipcode = Convert.ToInt32(textBox6.Text);
values[0] = zipcode;
MessageBox.Show("If all of your information is correct click OK", "Confirmation",
MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
//here the textboxes will be deleted on the message box disappears
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
textBox5.Text = "";
textBox6.Text = "";
textBox7.Text = "";
//here the values from the textboxes will be placed into the labels
label1.Text = values2[0];
label2.Text = values2[1];
label3.Text = values2[2];
label4.Text = values2[3];
label5.Text = values2[4];
label6.Text = Convert.ToString(values[0]);
label7.Text = values2[5];
}
private void button2_Click(object sender, EventArgs e)
{
//here the labels will be deleted when you click the button
label1.Text = "";
label2.Text = "";
label3.Text = "";
label4.Text = "";
label5.Text = "";
label6.Text = "";
label7.Text = "";
}
private void button3_Click(object sender, EventArgs e)
{
//here the application will close
this.Close();
}
}
}
Tuesday, January 26, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment