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 OriginalGriff 240
1 Kamal Rocks 184
2 PIEBALDconsult 150
3 BillWoodruff 148
4 Jochen Arndt 135
0 OriginalGriff 5,695
1 DamithSL 4,506
2 Maciej Los 4,007
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,190


Advertise | Privacy | Mobile
Web03 | 2.8.141216.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