Switch to full style
Codes, tips and tricks,discussions and solutions related to C#
Post a reply

calling method to form- displaying textbox data in messagbox

Thu Jun 25, 2009 1:19 am

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



Re: calling method to form- displaying textbox data in messagbox

Fri May 21, 2010 7:29 am

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 senderEventArgs e)
        {
            
int total Convert.ToInt32(textBox1.Text)+Convert.ToInt32(textBox2.Text);;
            
MessageBox.Show(String.Format("This is Your Total Number {0}",total),"Show",MessageBoxButtons.OKMessageBoxIcon.Information);
        }
    }


Post a reply
  Related Posts  to : calling method to form- displaying textbox data in messagbox
 Calling a Private Method in jsp     -  
 Calling an Overridden Method in php     -  
 add data from form1 textbox to form2 combo box     -  
 Displaying images from database instead of the url from data     -  
 Send data without a form     -  
 How to make PHP form data saved into txt file     -  
 form to insert data, upload many files and images , database     -  
 Earn $2 Per Form Filled. Now Hiring Data Entry Typists     -  
 AutoComplete TextBox     -  
 how to show hashmap value in a textbox     -  

Topic Tags

C# Forms