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 Richard MacCutchan 269
1 Aajmot Sk 252
2 Marcin Kozub 235
3 Sergey Alexandrovich Kryukov 185
4 Praneet Nadkar 167
0 OriginalGriff 7,913
1 Sergey Alexandrovich Kryukov 7,232
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,865


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