Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
| Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 26th, 2007, 08:01 PM
Authorized User
 
Join Date: Jan 2007
Location: , LA, .
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to seymour_glass
Default Using classes

OK I am making a calculator pretty much similar to the windows calculator. It uses buttons 0-9 and +, -, *, /, Clr buttons. In writing a class that would look something like:

Code:
public class MathFunctions
        {


            public int Add(int a, int b)
            {

                return(a + b);
            }
When the user clicks say 23 then + then 23, how do i handle the variables such that the function in my class will be called and add a + b (or in this case, 23 + 23) and returned to my textbox? I am not handling the strings in a "23+23" fashion...it is set up so that when the user clicks the plus the 23 is stored, and the textbox cleared for the next number...i am having problems with where to execute the code that calls my class and function...additionally, how would it be handled such that the total would be stored so that upon adding the next number, 46 would be my "a" variable.... Hope this isn't confusing...I know with addition I could do this easier but I am just trying something simple so that i have an understanding of how to handle the class so I can eventually use more complicated functions////

Seymour
 
Old April 26th, 2007, 10:18 PM
Authorized User
 
Join Date: Jan 2007
Location: , LA, .
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to seymour_glass
Default

never mind...ive figured that part out...now..to the NEXT part.




Similar Threads
Thread Thread Starter Forum Replies Last Post
HELP Problem With Classes nichola_x_rose ASP.NET 2.0 Professional 0 March 17th, 2007 07:56 AM
classes dhoward VB.NET 2002/2003 Basics 2 November 8th, 2006 10:35 AM
About Classes. wdw BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 July 29th, 2005 08:46 AM
Classes digby_dog VB.NET 2002/2003 Basics 1 May 2nd, 2005 09:12 PM
Classes CodeMonkeys C# 3 August 18th, 2004 11:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.