473,394 Members | 1,701 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

add textbox and button to output to messagebox in C#

107 100+
Hello, I have a class firstClass
Expand|Select|Wrap|Line Numbers
  1. public static int add(int numberOne, int numberTwo)
  2. {
  3.     return (numberOne + numberTwo);
  4. }
in form two texboxes and a button:
code for button is:
Expand|Select|Wrap|Line Numbers
  1. int total = firstClass.add(int.Parse(textBox1.Text), int.Parse(textBox2.Text));
  2.             MessageBox.Show(total.ToString());
I want to overload the method and allow strings instead of integers.
last I want to create another button and diplay in messagebox based on a third textbox.
thank you
Jun 21 '09 #1
4 8350
tlhintoq
3,525 Expert 2GB
Those are good 'wants'.

Did you have a question for the volunteers here?
Jun 21 '09 #2
buddyr
107 100+
to overload the method to allow strings can I use a method like:
Expand|Select|Wrap|Line Numbers
  1. public static int add( string stingOne, string stringTwo, stringThree)
  2. {
  3. return (int.Parse(stringOne) + int.Parse(stringTwo) + int.Parse(stringThree)
?
Jun 21 '09 #3
tlhintoq
3,525 Expert 2GB
@buddyr
Two part reply:
First: Don't be afraid to experiment. It takes 30 seconds to actually put that code in the program and try it. Writting it up for a forum then waiting on a reply is hours. Trial and error will teach you a lot more than someone giving you the yes/no answer.

Second:
Overloading is the technique of creating two methods of the same name with different parameter signatures.

These would all be valid signature overloads for a method called "CalculateTotal"
Expand|Select|Wrap|Line Numbers
  1. private int CalculateTotal(int nOne)
  2. private int CalculateTotal(int nOne, nTwo)
  3. private int CalculateTotal(List<int> nList)
  4. private int CalculateTotal(Decimal Yogi, float Booboo, string RangerSmith)
  5.  
So you tell me... Would these all be valid overloads for your method?
Expand|Select|Wrap|Line Numbers
  1. public static int add(string stingOne, string stringTwo, stringThree)
  2. public static int add(int numberOne, int numberTwo)
  3.  
Jun 21 '09 #4
buddyr
107 100+
Thank you - same method name with different combination of parameters and/or data types
Jun 21 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Sin | last post by:
I'm currently evaluating VC.NET as the new platform for the company I work for and things are looking grim... We're up against another IDE which took me about 5 minutes to master and I've been...
7
by: trint | last post by:
I have a textbox (textBox7) that isn't updating.. Is there a way, after I type new text in it, to have it update? It seems to be fairly normal: public class Form1 : System.Windows.Forms.Form {...
2
by: jzheng22 | last post by:
Hi all, I am new to VB .NET. I am currently wring a simple GUI, a TextBox (multilined), a button and an OpenFileDialog. When user click the button, the OpenFileDialog fired and after user...
21
by: Darin | last post by:
I have a form w/ a textbox and Cancel button on it. I have a routine to handle textbox.validating, and I have the form setup so the Cancel button is the Cancel button. WHen the user clicks on...
2
by: VMI | last post by:
In the Page_Load() of my webForm, I have the following code, and on my HTML button, the onclick button calls writeVal() (the javascript function). When I click on the button, I see the messagebox...
1
by: rn5a | last post by:
I want to create a custom control that encapsulates a Button & a TextBox. When the Button is clicked, the user is asked a question using JavaScript confirm (which shows 2 buttons - 'OK' &...
8
by: Randy | last post by:
I'm don't even know where to start on this one. I have a form where the user is allowed to add one row at a time to a table via textboxes. Imagine an order with an undefined number of items to be...
5
by: kimiraikkonen | last post by:
Hello, I have a textbox named "textbox1" and a button named "button1" How can i retrieve the console (cmd) data into textbox? For example when i run Shell("cmd.exe /k dir...
1
by: vayalumkan | last post by:
I have the following program (C# VS 2005) for validating an email id entered in a textbox. It works fine. Namespace used - using System.Text.RegularExpressions; At present I have written...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.