mercredi 31 décembre 2014

Dictionary key compare with textbox

hi people so what i want to do is check if text in multiple text boxes have the same text/name as keys in a dictionary and if it does i want it to get the value of they keys and add them together (if that makes sense) the if statements should go on till friday then after the program goes through the if statements it should add all the values of the keys together to generate the total and display it on a label (the values are decimals)


pictures http://ift.tt/13UdHqj http://ift.tt/1rBH1gd


code:



private void button2_Click(object sender, EventArgs e)
{
Dictionary<String, Decimal> dictionary1 = new Dictionary<String, Decimal>();
dictionary1.Add("Monday Express", Convert.ToDecimal(mondayExpressTextBox.Text));
dictionary1.Add("Monday FinancialTimes", Convert.ToDecimal(mondayFTTextBox.Text));
dictionary1.Add("Monday Guardian", Convert.ToDecimal(mondayGuardianTextBox.Text));
dictionary1.Add("Monday I", Convert.ToDecimal(mondayITextBox.Text));
dictionary1.Add("Monday Independant", Convert.ToDecimal(mondayIndependantTextBox.Text));
dictionary1.Add("Monday Jang", Convert.ToDecimal(mondayJangTextBox.Text));
dictionary1.Add("Monday Mail", Convert.ToDecimal(mondayMailTextBox.Text));
dictionary1.Add("Monday M.E.N", Convert.ToDecimal(mondayMENTextBox.Text));
dictionary1.Add("Monday ManchesterNew", Convert.ToDecimal(mondayManchesterNewTextBox.Text));
dictionary1.Add("Monday Mirror", Convert.ToDecimal(mondayMirrorTextBox.Text));
dictionary1.Add("Monday Oldham Chronical", Convert.ToDecimal(mondayTextBox.Text));
dictionary1.Add("Monday Racing Post", Convert.ToDecimal(mondayRacingPostTextBox.Text));
dictionary1.Add("Monday Racing Post Betting", Convert.ToDecimal(mondayRacingPostBettingTextBox.Text));
dictionary1.Add("Monday RLE", Convert.ToDecimal(mondayRLETextBox.Text));
dictionary1.Add("Monday Star", Convert.ToDecimal(mondayStarTextBox.Text));
dictionary1.Add("Monday SUN", Convert.ToDecimal(mondaySUNTextBox.Text));
dictionary1.Add("Monday Telegraph", Convert.ToDecimal(mondayTelegraphTextBox.Text));
dictionary1.Add("Monday Times", Convert.ToDecimal(mondayTimesTextBox.Text));
dictionary1.Add("Monday Yorkshire Post", Convert.ToDecimal(mondayYPTextBox.Text));

if (dictionary1.ContainsKey(mondayTextBox.Text))
{
if (dictionary1.ContainsKey(mondayTextBox.Text)){}
}
}

Aucun commentaire:

Enregistrer un commentaire