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. please help me how to fix this program this is a calculator in vb6.0

please help me how to fix this program this is a calculator in vb6.0

Scheduled Pinned Locked Moved Visual Basic
helpdatabasetutorial
15 Posts 7 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.
  • V Offline
    V Offline
    VBBeginerGSM
    wrote on last edited by
    #1

    Dim op As String Option Explicit Dim i As Integer Dim exp1 As Double Dim exp2 As Double Dim Result As Double Dim count1 As Integer Dim scitype As String Private X As Double Dim mem As Variant Private Sub Command1_Click(Index As Integer) If count1 = 0 Then Text1.Text = " " MsgBox ("Calculator is not on") End If If count1 = 1 Then Text1.Text = " " count1 = count1 + 1 End If If count1 > 1 Then Text1.Text = Text1.Text & command1(Index).Caption End If End Sub Private Sub Command10_Click() Text1.Text = mem End Sub Private Sub Command2_Click() Text1.Text = -Val(Text1.Text) End Sub Private Sub Command3_Click() If count1 > 0 Then exp2 = Val(Text1.Text) Select Case (op) Case "+" Result = exp1 + exp2 Text1.Text = Result count1 = 0 Case "-" Result = exp1 - exp2 Text1.Text = Result count1 = 0 Case "*" Result = exp1 * exp2 Text1.Text = Result count1 = 0 Case "/" Result = exp1 / exp2 Text1.Text = Result count1 = 0 Case "%" Result = (exp1 / 100) * exp2 Text1.Text = Result count1 = 0 End Select End If End Sub Private Sub Command4_Click(Index As Integer) Result = exp1 exp1 = Result + Val(Text1.Text) Text1.Text = " " op = Command4(Index).Caption End Sub Private Sub Command5_Click() Result = 0 exp1 = 0 exp2 = 0 Text1.Text = " " count1 = 1 End Sub Private Sub Command6_Click() count1 = 0 Text1.Text = "" End Sub Private Sub Command7_Click() Result = 0 exp1 = 0 exp2 = 0 count1 = 1 Text1.Text = "0" End Sub Private Sub UpdateLog() Trim (Form1.Text1.Text) End Sub Private Sub Command8_Click(Index As Integer) scitype = Command8(Index).Caption Select Case (scitype) Case "sin" Text1.Text = (Text1.Text * 3.14) / 180 Text1.Text = Math.Sin(Val(Text1.Text)) count1 = 0 Case "cos" Text1.Text = (Text1.Text * 3.14) / 180 Text1.Text = Math.Cos(Val(Text1.Text)) count1 = 0 Case "tan" Text1.Text = (Text1.Text * 3.14) / 180 Text1.Text = Math.Tan(Val(Text1.Text)) count1 = 0 Case "sqrt" Text1.Text = Math.Sqr(Val(Text1.Text)) count1 = 0 Case "abs" Text1.Text = Math.Abs(Val(Text1.Text)) count1 = 0 Case "rnd" Text1.Text = Math.Rnd(Val(Text1.Text)) count1 = 0 Case "log" Text1.Text = Math.Log(Val(Text1.Text)) count1 = 0 Case "Atn"

    S V R D 4 Replies Last reply
    0
    • V VBBeginerGSM

      Dim op As String Option Explicit Dim i As Integer Dim exp1 As Double Dim exp2 As Double Dim Result As Double Dim count1 As Integer Dim scitype As String Private X As Double Dim mem As Variant Private Sub Command1_Click(Index As Integer) If count1 = 0 Then Text1.Text = " " MsgBox ("Calculator is not on") End If If count1 = 1 Then Text1.Text = " " count1 = count1 + 1 End If If count1 > 1 Then Text1.Text = Text1.Text & command1(Index).Caption End If End Sub Private Sub Command10_Click() Text1.Text = mem End Sub Private Sub Command2_Click() Text1.Text = -Val(Text1.Text) End Sub Private Sub Command3_Click() If count1 > 0 Then exp2 = Val(Text1.Text) Select Case (op) Case "+" Result = exp1 + exp2 Text1.Text = Result count1 = 0 Case "-" Result = exp1 - exp2 Text1.Text = Result count1 = 0 Case "*" Result = exp1 * exp2 Text1.Text = Result count1 = 0 Case "/" Result = exp1 / exp2 Text1.Text = Result count1 = 0 Case "%" Result = (exp1 / 100) * exp2 Text1.Text = Result count1 = 0 End Select End If End Sub Private Sub Command4_Click(Index As Integer) Result = exp1 exp1 = Result + Val(Text1.Text) Text1.Text = " " op = Command4(Index).Caption End Sub Private Sub Command5_Click() Result = 0 exp1 = 0 exp2 = 0 Text1.Text = " " count1 = 1 End Sub Private Sub Command6_Click() count1 = 0 Text1.Text = "" End Sub Private Sub Command7_Click() Result = 0 exp1 = 0 exp2 = 0 count1 = 1 Text1.Text = "0" End Sub Private Sub UpdateLog() Trim (Form1.Text1.Text) End Sub Private Sub Command8_Click(Index As Integer) scitype = Command8(Index).Caption Select Case (scitype) Case "sin" Text1.Text = (Text1.Text * 3.14) / 180 Text1.Text = Math.Sin(Val(Text1.Text)) count1 = 0 Case "cos" Text1.Text = (Text1.Text * 3.14) / 180 Text1.Text = Math.Cos(Val(Text1.Text)) count1 = 0 Case "tan" Text1.Text = (Text1.Text * 3.14) / 180 Text1.Text = Math.Tan(Val(Text1.Text)) count1 = 0 Case "sqrt" Text1.Text = Math.Sqr(Val(Text1.Text)) count1 = 0 Case "abs" Text1.Text = Math.Abs(Val(Text1.Text)) count1 = 0 Case "rnd" Text1.Text = Math.Rnd(Val(Text1.Text)) count1 = 0 Case "log" Text1.Text = Math.Log(Val(Text1.Text)) count1 = 0 Case "Atn"

      S Offline
      S Offline
      Simon_Whale
      wrote on last edited by
      #2

      And the error is where? and what?

      Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch

      1 Reply Last reply
      0
      • V VBBeginerGSM

        Dim op As String Option Explicit Dim i As Integer Dim exp1 As Double Dim exp2 As Double Dim Result As Double Dim count1 As Integer Dim scitype As String Private X As Double Dim mem As Variant Private Sub Command1_Click(Index As Integer) If count1 = 0 Then Text1.Text = " " MsgBox ("Calculator is not on") End If If count1 = 1 Then Text1.Text = " " count1 = count1 + 1 End If If count1 > 1 Then Text1.Text = Text1.Text & command1(Index).Caption End If End Sub Private Sub Command10_Click() Text1.Text = mem End Sub Private Sub Command2_Click() Text1.Text = -Val(Text1.Text) End Sub Private Sub Command3_Click() If count1 > 0 Then exp2 = Val(Text1.Text) Select Case (op) Case "+" Result = exp1 + exp2 Text1.Text = Result count1 = 0 Case "-" Result = exp1 - exp2 Text1.Text = Result count1 = 0 Case "*" Result = exp1 * exp2 Text1.Text = Result count1 = 0 Case "/" Result = exp1 / exp2 Text1.Text = Result count1 = 0 Case "%" Result = (exp1 / 100) * exp2 Text1.Text = Result count1 = 0 End Select End If End Sub Private Sub Command4_Click(Index As Integer) Result = exp1 exp1 = Result + Val(Text1.Text) Text1.Text = " " op = Command4(Index).Caption End Sub Private Sub Command5_Click() Result = 0 exp1 = 0 exp2 = 0 Text1.Text = " " count1 = 1 End Sub Private Sub Command6_Click() count1 = 0 Text1.Text = "" End Sub Private Sub Command7_Click() Result = 0 exp1 = 0 exp2 = 0 count1 = 1 Text1.Text = "0" End Sub Private Sub UpdateLog() Trim (Form1.Text1.Text) End Sub Private Sub Command8_Click(Index As Integer) scitype = Command8(Index).Caption Select Case (scitype) Case "sin" Text1.Text = (Text1.Text * 3.14) / 180 Text1.Text = Math.Sin(Val(Text1.Text)) count1 = 0 Case "cos" Text1.Text = (Text1.Text * 3.14) / 180 Text1.Text = Math.Cos(Val(Text1.Text)) count1 = 0 Case "tan" Text1.Text = (Text1.Text * 3.14) / 180 Text1.Text = Math.Tan(Val(Text1.Text)) count1 = 0 Case "sqrt" Text1.Text = Math.Sqr(Val(Text1.Text)) count1 = 0 Case "abs" Text1.Text = Math.Abs(Val(Text1.Text)) count1 = 0 Case "rnd" Text1.Text = Math.Rnd(Val(Text1.Text)) count1 = 0 Case "log" Text1.Text = Math.Log(Val(Text1.Text)) count1 = 0 Case "Atn"

        V Offline
        V Offline
        VBBeginerGSM
        wrote on last edited by
        #3

        SIR i don't know how to fix it in command botton please help me u have facebook? please add me michaelgsm22@yahoo.com I w8 your response

        modified on Monday, August 22, 2011 10:23 AM

        S S 2 Replies Last reply
        0
        • V VBBeginerGSM

          Dim op As String Option Explicit Dim i As Integer Dim exp1 As Double Dim exp2 As Double Dim Result As Double Dim count1 As Integer Dim scitype As String Private X As Double Dim mem As Variant Private Sub Command1_Click(Index As Integer) If count1 = 0 Then Text1.Text = " " MsgBox ("Calculator is not on") End If If count1 = 1 Then Text1.Text = " " count1 = count1 + 1 End If If count1 > 1 Then Text1.Text = Text1.Text & command1(Index).Caption End If End Sub Private Sub Command10_Click() Text1.Text = mem End Sub Private Sub Command2_Click() Text1.Text = -Val(Text1.Text) End Sub Private Sub Command3_Click() If count1 > 0 Then exp2 = Val(Text1.Text) Select Case (op) Case "+" Result = exp1 + exp2 Text1.Text = Result count1 = 0 Case "-" Result = exp1 - exp2 Text1.Text = Result count1 = 0 Case "*" Result = exp1 * exp2 Text1.Text = Result count1 = 0 Case "/" Result = exp1 / exp2 Text1.Text = Result count1 = 0 Case "%" Result = (exp1 / 100) * exp2 Text1.Text = Result count1 = 0 End Select End If End Sub Private Sub Command4_Click(Index As Integer) Result = exp1 exp1 = Result + Val(Text1.Text) Text1.Text = " " op = Command4(Index).Caption End Sub Private Sub Command5_Click() Result = 0 exp1 = 0 exp2 = 0 Text1.Text = " " count1 = 1 End Sub Private Sub Command6_Click() count1 = 0 Text1.Text = "" End Sub Private Sub Command7_Click() Result = 0 exp1 = 0 exp2 = 0 count1 = 1 Text1.Text = "0" End Sub Private Sub UpdateLog() Trim (Form1.Text1.Text) End Sub Private Sub Command8_Click(Index As Integer) scitype = Command8(Index).Caption Select Case (scitype) Case "sin" Text1.Text = (Text1.Text * 3.14) / 180 Text1.Text = Math.Sin(Val(Text1.Text)) count1 = 0 Case "cos" Text1.Text = (Text1.Text * 3.14) / 180 Text1.Text = Math.Cos(Val(Text1.Text)) count1 = 0 Case "tan" Text1.Text = (Text1.Text * 3.14) / 180 Text1.Text = Math.Tan(Val(Text1.Text)) count1 = 0 Case "sqrt" Text1.Text = Math.Sqr(Val(Text1.Text)) count1 = 0 Case "abs" Text1.Text = Math.Abs(Val(Text1.Text)) count1 = 0 Case "rnd" Text1.Text = Math.Rnd(Val(Text1.Text)) count1 = 0 Case "log" Text1.Text = Math.Log(Val(Text1.Text)) count1 = 0 Case "Atn"

          R Offline
          R Offline
          riced
          wrote on last edited by
          #4

          Tells us what is going wrong - does it fail to run? give the wrong answers? bomb out in the middle of a calculation? If you do that someone might help. I guess however that the most profitable advice would be to stop using VB6 and use VB.Net instead. Posting your address on Facebook is not likely to bring results and is not a good idea.

          Regards David R --------------------------------------------------------------- "Every program eventually becomes rococo, and then rubble." - Alan Perlis The only valid measurement of code quality: WTFs/minute.

          V 1 Reply Last reply
          0
          • R riced

            Tells us what is going wrong - does it fail to run? give the wrong answers? bomb out in the middle of a calculation? If you do that someone might help. I guess however that the most profitable advice would be to stop using VB6 and use VB.Net instead. Posting your address on Facebook is not likely to bring results and is not a good idea.

            Regards David R --------------------------------------------------------------- "Every program eventually becomes rococo, and then rubble." - Alan Perlis The only valid measurement of code quality: WTFs/minute.

            V Offline
            V Offline
            VBBeginerGSM
            wrote on last edited by
            #5

            sir the code is ok but i do'nt know how to fix it in command buttons huh !

            S R 2 Replies Last reply
            0
            • V VBBeginerGSM

              sir the code is ok but i do'nt know how to fix it in command buttons huh !

              S Offline
              S Offline
              Simon_Whale
              wrote on last edited by
              #6

              Describe what you are after doing and which command button that you want it doing. But as people have said VB6 isn't a supported language anymore and most people that do VB in its many guises have moved across to .net

              Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch

              1 Reply Last reply
              0
              • V VBBeginerGSM

                sir the code is ok but i do'nt know how to fix it in command buttons huh !

                R Offline
                R Offline
                riced
                wrote on last edited by
                #7

                IIRC double click the button in the designer. That takes you to the code window with a stub for the buttons click event. Put your code in the stub. I think the last time I used VB6 was in 2000 so it's a bit rusty. You might be able to do it from the properties window in the designer - I have a sneaking feeling that you can but it is better to use double click method. VB6 seemed to get confused otherwise (again I might have misremembered.)

                Regards David R --------------------------------------------------------------- "Every program eventually becomes rococo, and then rubble." - Alan Perlis The only valid measurement of code quality: WTFs/minute.

                V 1 Reply Last reply
                0
                • V VBBeginerGSM

                  SIR i don't know how to fix it in command botton please help me u have facebook? please add me michaelgsm22@yahoo.com I w8 your response

                  modified on Monday, August 22, 2011 10:23 AM

                  S Offline
                  S Offline
                  Smithers Jones
                  wrote on last edited by
                  #8

                  No need to discuss this on Facebook, since you probably have realised, that this is a - as you also might have guessed from the page menu already - "discussion forum". Isn't that nice? So no need to change to a stupid platform for which you have to do a new registration in case you're not a member yet. By the way, it's "I wait", not "I w8". Don't use textspeak, you are not five years old (probably).

                  "I love deadlines. I like the whooshing sound they make as they fly by." (DNA)

                  1 Reply Last reply
                  0
                  • R riced

                    IIRC double click the button in the designer. That takes you to the code window with a stub for the buttons click event. Put your code in the stub. I think the last time I used VB6 was in 2000 so it's a bit rusty. You might be able to do it from the properties window in the designer - I have a sneaking feeling that you can but it is better to use double click method. VB6 seemed to get confused otherwise (again I might have misremembered.)

                    Regards David R --------------------------------------------------------------- "Every program eventually becomes rococo, and then rubble." - Alan Perlis The only valid measurement of code quality: WTFs/minute.

                    V Offline
                    V Offline
                    VBBeginerGSM
                    wrote on last edited by
                    #9

                    sir ido'nt know were commandbottons i put the code please teach me!

                    D 1 Reply Last reply
                    0
                    • V VBBeginerGSM

                      sir ido'nt know were commandbottons i put the code please teach me!

                      D Offline
                      D Offline
                      DaveAuld
                      wrote on last edited by
                      #10

                      In the code pane of the IDE, you have 2 drop down's at the top, the left one is the object and the right one is the event. SO in the the left one, choose a command button. In the right one, choose Click. A code stub will appear in the text editor. Enter the code within this stub. Sounds like you need to go right back to Page 1 of your course book, before you even worry about trying to code in inner workings of a calculator.

                      Dave Find Me On: Web|Facebook|Twitter|LinkedIn


                      Folding Stats: Team CodeProject

                      V 1 Reply Last reply
                      0
                      • D DaveAuld

                        In the code pane of the IDE, you have 2 drop down's at the top, the left one is the object and the right one is the event. SO in the the left one, choose a command button. In the right one, choose Click. A code stub will appear in the text editor. Enter the code within this stub. Sounds like you need to go right back to Page 1 of your course book, before you even worry about trying to code in inner workings of a calculator.

                        Dave Find Me On: Web|Facebook|Twitter|LinkedIn


                        Folding Stats: Team CodeProject

                        V Offline
                        V Offline
                        VBBeginerGSM
                        wrote on last edited by
                        #11

                        sir I add u in FB! please acept it!

                        1 Reply Last reply
                        0
                        • V VBBeginerGSM

                          SIR i don't know how to fix it in command botton please help me u have facebook? please add me michaelgsm22@yahoo.com I w8 your response

                          modified on Monday, August 22, 2011 10:23 AM

                          S Offline
                          S Offline
                          slam Iqbal
                          wrote on last edited by
                          #12

                          So, Can you tell us from where you copy this code?

                          V 1 Reply Last reply
                          0
                          • V VBBeginerGSM

                            Dim op As String Option Explicit Dim i As Integer Dim exp1 As Double Dim exp2 As Double Dim Result As Double Dim count1 As Integer Dim scitype As String Private X As Double Dim mem As Variant Private Sub Command1_Click(Index As Integer) If count1 = 0 Then Text1.Text = " " MsgBox ("Calculator is not on") End If If count1 = 1 Then Text1.Text = " " count1 = count1 + 1 End If If count1 > 1 Then Text1.Text = Text1.Text & command1(Index).Caption End If End Sub Private Sub Command10_Click() Text1.Text = mem End Sub Private Sub Command2_Click() Text1.Text = -Val(Text1.Text) End Sub Private Sub Command3_Click() If count1 > 0 Then exp2 = Val(Text1.Text) Select Case (op) Case "+" Result = exp1 + exp2 Text1.Text = Result count1 = 0 Case "-" Result = exp1 - exp2 Text1.Text = Result count1 = 0 Case "*" Result = exp1 * exp2 Text1.Text = Result count1 = 0 Case "/" Result = exp1 / exp2 Text1.Text = Result count1 = 0 Case "%" Result = (exp1 / 100) * exp2 Text1.Text = Result count1 = 0 End Select End If End Sub Private Sub Command4_Click(Index As Integer) Result = exp1 exp1 = Result + Val(Text1.Text) Text1.Text = " " op = Command4(Index).Caption End Sub Private Sub Command5_Click() Result = 0 exp1 = 0 exp2 = 0 Text1.Text = " " count1 = 1 End Sub Private Sub Command6_Click() count1 = 0 Text1.Text = "" End Sub Private Sub Command7_Click() Result = 0 exp1 = 0 exp2 = 0 count1 = 1 Text1.Text = "0" End Sub Private Sub UpdateLog() Trim (Form1.Text1.Text) End Sub Private Sub Command8_Click(Index As Integer) scitype = Command8(Index).Caption Select Case (scitype) Case "sin" Text1.Text = (Text1.Text * 3.14) / 180 Text1.Text = Math.Sin(Val(Text1.Text)) count1 = 0 Case "cos" Text1.Text = (Text1.Text * 3.14) / 180 Text1.Text = Math.Cos(Val(Text1.Text)) count1 = 0 Case "tan" Text1.Text = (Text1.Text * 3.14) / 180 Text1.Text = Math.Tan(Val(Text1.Text)) count1 = 0 Case "sqrt" Text1.Text = Math.Sqr(Val(Text1.Text)) count1 = 0 Case "abs" Text1.Text = Math.Abs(Val(Text1.Text)) count1 = 0 Case "rnd" Text1.Text = Math.Rnd(Val(Text1.Text)) count1 = 0 Case "log" Text1.Text = Math.Log(Val(Text1.Text)) count1 = 0 Case "Atn"

                            D Offline
                            D Offline
                            Dalek Dave
                            wrote on last edited by
                            #13

                            This is easily fixed. Tell us what the error is, and where it is occuring. Tell us what you have so far attempted. Do not use Facebook or Textspeak, we are not morons.

                            ------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave CCC Link[^] Trolls[^]

                            1 Reply Last reply
                            0
                            • S slam Iqbal

                              So, Can you tell us from where you copy this code?

                              V Offline
                              V Offline
                              VBBeginerGSM
                              wrote on last edited by
                              #14

                              in my proff. this my project in 1st sem sir help me!

                              S 1 Reply Last reply
                              0
                              • V VBBeginerGSM

                                in my proff. this my project in 1st sem sir help me!

                                S Offline
                                S Offline
                                slam Iqbal
                                wrote on last edited by
                                #15

                                Add all the command buttons and text boxes. For Command1 only (as the code tell us), copy it & paste it to form to create an array of command. I don't know how long the array would be.

                                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