Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. button + in calc works bad.

button + in calc works bad.

Scheduled Pinned Locked Moved Visual Basic
questionhelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hasani2007
    wrote on last edited by
    #1

    Hello all; I have a question for my calculator project. command13 is a + button. when you sum 2 number it works correctly. but if you press this button for second time it will sum the last result with itself & again & again if you press + button. NOW HELP ME : what should I do to avoid sum in 2nd,3rd,... button click? snippet code is appended. Private Sub Command13_Click() Combo1.AddItem Combo1.Text Combo1.AddItem "+" 'b = Combo1.ListCount Select Case o Case Is = 1 Combo1.Text = a + Val(Combo1.Text) Case Is = 2 Combo1.Text = a - Val(Combo1.Text) Case Is = 3 Combo1.Text = a * Val(Combo1.Text) Case Is = 4 Combo1.Text = a / Val(Combo1.Text) End Select a = Val(Combo1.Text) h = 1 o = 1 End Sub Thanks anyone help me...

    L 1 Reply Last reply
    0
    • H hasani2007

      Hello all; I have a question for my calculator project. command13 is a + button. when you sum 2 number it works correctly. but if you press this button for second time it will sum the last result with itself & again & again if you press + button. NOW HELP ME : what should I do to avoid sum in 2nd,3rd,... button click? snippet code is appended. Private Sub Command13_Click() Combo1.AddItem Combo1.Text Combo1.AddItem "+" 'b = Combo1.ListCount Select Case o Case Is = 1 Combo1.Text = a + Val(Combo1.Text) Case Is = 2 Combo1.Text = a - Val(Combo1.Text) Case Is = 3 Combo1.Text = a * Val(Combo1.Text) Case Is = 4 Combo1.Text = a / Val(Combo1.Text) End Select a = Val(Combo1.Text) h = 1 o = 1 End Sub Thanks anyone help me...

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      some calculators work that way; others don't want to perform a second operation until a new number has been entered. decide what functionality you want, then implement it. if necessary keep track of what happened most recently (enter number parts, i.e. digits, minus sign, period) or click operator. :)

      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


      I only read formatted code with indentation, so please use PRE tags for code snippets.


      I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).


      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups