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. How to build a simple calculator?

How to build a simple calculator?

Scheduled Pinned Locked Moved Visual Basic
helpcsharptutorialquestion
24 Posts 6 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.
  • T Tamimi Code

    is this a home work ?? :cool:

    Tamimi - Code

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #4

    why u joking on him, i chalenge u to make it

    Mohamad A. Flefel C#.net Developer

    T 1 Reply Last reply
    0
    • L Lost User

      it too Simple and i will not tell u about it , think Alone

      Mohamad A. Flefel
      +962 79 5963865
      C#.net Developer

      T Offline
      T Offline
      Tamimi Code
      wrote on last edited by
      #5

      i think that that you to dont know how to do it :laugh::laugh::laugh::laugh:

      Tamimi - Code

      A 1 Reply Last reply
      0
      • L Lost User

        why u joking on him, i chalenge u to make it

        Mohamad A. Flefel C#.net Developer

        T Offline
        T Offline
        Tamimi Code
        wrote on last edited by
        #6

        i think abo rami could !!!!!!!!!1

        Tamimi - Code

        L 1 Reply Last reply
        0
        • T Tamimi Code

          i think abo rami could !!!!!!!!!1

          Tamimi - Code

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #7

          we ethier find a way or die Trieng :laugh::laugh:

          Mohamad A. Flefel C#.net Developer

          1 Reply Last reply
          0
          • T Tamimi Code

            i think that that you to dont know how to do it :laugh::laugh::laugh::laugh:

            Tamimi - Code

            A Offline
            A Offline
            aurora56
            wrote on last edited by
            #8

            -_-".... ur r making things diff4 me.. n i'm a she not him. n yes, this is a homework. =p

            T L 2 Replies Last reply
            0
            • A aurora56

              -_-".... ur r making things diff4 me.. n i'm a she not him. n yes, this is a homework. =p

              T Offline
              T Offline
              Tamimi Code
              wrote on last edited by
              #9

              try to do it by your self, when you facing a problem come back here and you will be answered

              Tamimi - Code

              A 1 Reply Last reply
              0
              • A aurora56

                I had a problem. I had to create a simple calculator with VB.Net and this calculator had 0-9 buttons, add and minus function, a = button and a textbox for display of answer. I couldnt figure out the codings for the buttons. hope your can help me. thank you! =)

                C Offline
                C Offline
                Christian Graus
                wrote on last edited by
                #10

                You got the response you did because we don't do people's homework here. If you try to do your own homework, then we're happy to help with specifics.

                Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

                1 Reply Last reply
                0
                • T Tamimi Code

                  try to do it by your self, when you facing a problem come back here and you will be answered

                  Tamimi - Code

                  A Offline
                  A Offline
                  aurora56
                  wrote on last edited by
                  #11

                  hmmm... well... i have done the codings for each individual buttons. Eg for the button 9: Private Sub btn9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn9.Click TextBox1.Text = 9 temp = 9 End Sub However, I can't figure out what should the code of '+' be. Since when a user clicks on it, he/she will select another number button. So is it simply this: TextBox1.Text = Int(TextBox1.Text) + Int(TextBox1.Text)

                  L 1 Reply Last reply
                  0
                  • A aurora56

                    hmmm... well... i have done the codings for each individual buttons. Eg for the button 9: Private Sub btn9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn9.Click TextBox1.Text = 9 temp = 9 End Sub However, I can't figure out what should the code of '+' be. Since when a user clicks on it, he/she will select another number button. So is it simply this: TextBox1.Text = Int(TextBox1.Text) + Int(TextBox1.Text)

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #12

                    u remind for someone called safrooooooooooooooooooooooooooooooot

                    Mohamad A. Flefel C#.net Developer

                    1 Reply Last reply
                    0
                    • A aurora56

                      -_-".... ur r making things diff4 me.. n i'm a she not him. n yes, this is a homework. =p

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #13

                      hi ( SHE ) u had entered a programmers site u can't ask questions like this

                      Mohamad A. Flefel mflefel@hotmail.com C#.net Developer

                      A 1 Reply Last reply
                      0
                      • L Lost User

                        hi ( SHE ) u had entered a programmers site u can't ask questions like this

                        Mohamad A. Flefel mflefel@hotmail.com C#.net Developer

                        A Offline
                        A Offline
                        aurora56
                        wrote on last edited by
                        #14

                        Really? oh, ok. thx for trying to help me. i'll try to figure it out then . thank u....

                        L 1 Reply Last reply
                        0
                        • A aurora56

                          Really? oh, ok. thx for trying to help me. i'll try to figure it out then . thank u....

                          L Offline
                          L Offline
                          Lost User
                          wrote on last edited by
                          #15

                          i had made a sample calculater i can send it to u its code is very easy

                          Mohamad A. Flefel mflefel@hotmail.com +962 79 5963865 C#.net Developer

                          A L 2 Replies Last reply
                          0
                          • L Lost User

                            i had made a sample calculater i can send it to u its code is very easy

                            Mohamad A. Flefel mflefel@hotmail.com +962 79 5963865 C#.net Developer

                            A Offline
                            A Offline
                            aurora56
                            wrote on last edited by
                            #16

                            Hmm.. no thank you. I think is better if i figure it out myself or maybe you can try help me with my codings. =)

                            1 Reply Last reply
                            0
                            • L Lost User

                              i had made a sample calculater i can send it to u its code is very easy

                              Mohamad A. Flefel mflefel@hotmail.com +962 79 5963865 C#.net Developer

                              L Offline
                              L Offline
                              Lost User
                              wrote on last edited by
                              #17

                              ok , here is my e-mail u can ask for help any time :)

                              Mohamad A. Flefel mflefel@hotmail.com +962 79 5963865 C#.net Developer

                              A T 2 Replies Last reply
                              0
                              • L Lost User

                                ok , here is my e-mail u can ask for help any time :)

                                Mohamad A. Flefel mflefel@hotmail.com +962 79 5963865 C#.net Developer

                                T Offline
                                T Offline
                                Tamimi Code
                                wrote on last edited by
                                #18

                                dont ever put you email on a fourm :suss:

                                Tamimi - Code

                                1 Reply Last reply
                                0
                                • L Lost User

                                  ok , here is my e-mail u can ask for help any time :)

                                  Mohamad A. Flefel mflefel@hotmail.com +962 79 5963865 C#.net Developer

                                  A Offline
                                  A Offline
                                  aurora56
                                  wrote on last edited by
                                  #19

                                  =) thank you. i have done the codings for each individual buttons. Eg for the button 9: Private Sub btn9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn9.Click TextBox1.Text = 9 temp = 9 End Sub However, I can't figure out what should the code of '+' be. Since when a user clicks on it, he/she will select another number button. So is it simply this: TextBox1.Text = Int(TextBox1.Text) + Int(TextBox1.Text)

                                  C 1 Reply Last reply
                                  0
                                  • A aurora56

                                    =) thank you. i have done the codings for each individual buttons. Eg for the button 9: Private Sub btn9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn9.Click TextBox1.Text = 9 temp = 9 End Sub However, I can't figure out what should the code of '+' be. Since when a user clicks on it, he/she will select another number button. So is it simply this: TextBox1.Text = Int(TextBox1.Text) + Int(TextBox1.Text)

                                    C Offline
                                    C Offline
                                    Colin Angus Mackay
                                    wrote on last edited by
                                    #20

                                    Here are some pointers: You need to hold some state somewhere. You also need to hold the fact that the user can type numbers like 98 (the code you showed does not append more digits, it replaces them). When a use clicks on an operator button (+-/*=) the program needs to store the current display, then it needs to accept a new number. When the user next pressed an operator it performs the function of the operator on the stored value and the current value. When a user clicks on a digit button it has to append the value on to the other digits received.


                                    Upcoming Scottish Developers events: * UK Security Evangelists On Tour (2nd November, Edinburgh) * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog

                                    1 Reply Last reply
                                    0
                                    • A aurora56

                                      I had a problem. I had to create a simple calculator with VB.Net and this calculator had 0-9 buttons, add and minus function, a = button and a textbox for display of answer. I couldnt figure out the codings for the buttons. hope your can help me. thank you! =)

                                      R Offline
                                      R Offline
                                      Reuven Elliassi
                                      wrote on last edited by
                                      #21

                                      I have some idea for you: A. For the numeric buttons write scrip like this: private sub btn1_click(..) txtT.text = txtT.text & "1 end sub ' etc. for all numeric buttons B. For command buttons ( + - * / etc. ) write this script: private sub plus_click(..) Tmp1 = cint(txtT.text) act="plus" txtT.text="" end sub C. For = button write: private sub ans_click(..) Tmp2 = cint(txtT.text) select case act case "plus" : txtT.text = tmp1+tmp2 case "minus" : txtT.text = tmp1-tmp2 .... end select end sub This code handle only one action per two numbers. If you wans to handle lot of actions, like windows calculator, you need to add a boolean trigger that will be True if one action had been chosen and when the user select another action it will do the action selected before, then put the result in Tmp1 and then reset the trigger to False. This process will continue until the user click the = button. I'll don't give the answer for this so quickly .. ;) I give you time to think about it.

                                      A 1 Reply Last reply
                                      0
                                      • R Reuven Elliassi

                                        I have some idea for you: A. For the numeric buttons write scrip like this: private sub btn1_click(..) txtT.text = txtT.text & "1 end sub ' etc. for all numeric buttons B. For command buttons ( + - * / etc. ) write this script: private sub plus_click(..) Tmp1 = cint(txtT.text) act="plus" txtT.text="" end sub C. For = button write: private sub ans_click(..) Tmp2 = cint(txtT.text) select case act case "plus" : txtT.text = tmp1+tmp2 case "minus" : txtT.text = tmp1-tmp2 .... end select end sub This code handle only one action per two numbers. If you wans to handle lot of actions, like windows calculator, you need to add a boolean trigger that will be True if one action had been chosen and when the user select another action it will do the action selected before, then put the result in Tmp1 and then reset the trigger to False. This process will continue until the user click the = button. I'll don't give the answer for this so quickly .. ;) I give you time to think about it.

                                        A Offline
                                        A Offline
                                        aurora56
                                        wrote on last edited by
                                        #22

                                        =) thank u! i'll try later. oh ya. do you know of some websites which have tutorials? our lecturers just threw us this homework without giving any help... once again, thanks! hope you have a great day!!

                                        C R 2 Replies Last reply
                                        0
                                        • A aurora56

                                          =) thank u! i'll try later. oh ya. do you know of some websites which have tutorials? our lecturers just threw us this homework without giving any help... once again, thanks! hope you have a great day!!

                                          C Offline
                                          C Offline
                                          Christian Graus
                                          wrote on last edited by
                                          #23

                                          aurora56 wrote:

                                          do you know of some websites which have tutorials?

                                          Well, based on this question

                                          aurora56 wrote:

                                          our lecturers just threw us this homework without giving any help...

                                          I suspect this is not true. Giving you code is not helping you. The answer to all of this is just a google away. If you can't do the most basic research, you need to quit your course.

                                          Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

                                          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