Question subject: calling method to form- displaying textbox data in messagbox
Posted: Thu Jun 25, 2009 1:19 am
Joined: Thu Jun 25, 2009 1:03 am Posts: 2 Has thanked: 0 time Have thanks: 0 time
Hello, have a ovveride method:
Code:
Public class MyDerivedClass : MyBaseClass { public override int Calculate() { return numberOne * numberTwo; } I call the method in button command: private void button1_Click(object sender, EventArgs e) { MyDerivedClass mdc = new MyDerivedClass();
mdc.SumAll(); Question: I have two text boxes on form and one button. I want to input numbers in textboxes and click button to displaytotal in a messagebox. I have tried: myDerivedClass mdc = new myDerivedClass(); int total = mdc.calculate(); total=(int.Parse(textBox1.Text)) + (int.Parse(textBox2.Text)); MessageBox.Show(total.ToString());
but I am not sure I am realy calling the method doing it this way- any ideas thank you
orion
Question subject: Re: calling method to form- displaying textbox data in messagbox
Posted: Fri May 21, 2010 7:29 am
Joined: Sat Jan 17, 2009 7:51 pm Posts: 13 Has thanked: 0 time Have thanks: 1 time
Hi, May be help this code.
Code:
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 sHow_in_Messagebox { public partial class Form1 : Form { public Form1() { InitializeComponent(); }
private void button1_Click(object sender, EventArgs e) { int total = Convert.ToInt32(textBox1.Text)+Convert.ToInt32(textBox2.Text);; MessageBox.Show(String.Format("This is Your Total Number {0}",total),"Show",MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
For this message the author orion has received gratitude : msi_333