Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET SQL-Server buttons , +
How to accept values into array using Textbox and display the Sum of numbers using a Button?
Posted 23-Feb-13 1:40am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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 WindowsFormsApplication8
{
public partial class Form2 : Form
{
int[] n1 = new int[3];

public Form2()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
//n1[0] = Int32.Parse(textBox1.Text);
//n1[1] = Int32.Parse(textBox2.Text);
//n1[2] = Int32.Parse(textBox3.Text);
//textBox4.Text = n1.Sum().ToString();
 
int value;
 
if (int.TryParse(textBox1.Text, out value))
n1[0] = value;
if (int.TryParse(textBox2.Text, out value))
n1[1] = value;
if (int.TryParse(textBox3.Text, out value))
n1[2] = value;
textBox4.Text = n1.Sum().ToString();
 

}
}
}
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 BillWoodruff 260
1 Afzaal Ahmad Zeeshan 252
2 OriginalGriff 251
3 Mathew Soji 234
4 Maciej Los 230
0 OriginalGriff 6,419
1 Sergey Alexandrovich Kryukov 6,008
2 DamithSL 5,183
3 Manas Bhardwaj 4,673
4 Maciej Los 4,070


Advertise | Privacy | Mobile
Web04 | 2.8.1411019.1 | Last Updated 23 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100