DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2005
    Posts
    2

    Unhappy Windows calculator

    Hey ppl,

    can anybody help me in makeing a calculator like the windows calculator i need to know the code for the = button i have the first line,

    Private Sub btnequals_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnequals.Click
    total2 = total1 + (txtdisplay.Text)

    End Sub

    i just cant work out the next to

    thanks cutey_kira
    Edit/Delete Message

  2. #2
    Join Date
    Oct 2005
    Location
    York, PA (work in Baltimore, MD)
    Posts
    6
    The equals button should use the same code as hitting an operator for the second/third/etc time. For example:

    3 * 3 * 3 --> after hitting * for the 2nd time you'd expect the screen to display 9
    3 + 3 + 3 --> after hitting + for the 2nd time you'd expect the screen to display 6
    3 + 3 - 3 --> same as above

    Hitting = should do the same thing. Basically:
    if (priorOperator = '+') then
    result = priorTotal + txtDisplay.Text
    else if (priorOperator = '-') then
    result = priorTotal - txtDisplay.Text
    else if (priorOperator = '/') then
    result = priorTotal / txtDisplay.Text
    else if (priorOperator = '*') then
    result = priorTotal * txtDisplay.Text

    Hope this helps,
    Josh Lindenmuth
    Josh Lindenmuth - Payce Payroll

Similar Threads

  1. REAL Software Ships REALbasic 5 for WINDOWS
    By Gwen Smith in forum vb.announcements
    Replies: 0
    Last Post: 04-28-2003, 02:37 PM
  2. Replies: 2
    Last Post: 11-25-2002, 02:54 PM
  3. ?API NT Compatability?
    By Dennis in forum VB Classic
    Replies: 10
    Last Post: 02-15-2001, 03:52 AM
  4. Replies: 8
    Last Post: 01-19-2001, 05:50 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links