please help me how to fix this program this is a calculator in vb6.0
-
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"
-
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"
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
-
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"
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
-
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"
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.
-
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.
sir the code is ok but i do'nt know how to fix it in command buttons huh !
-
sir the code is ok but i do'nt know how to fix it in command buttons huh !
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
-
sir the code is ok but i do'nt know how to fix it in command buttons huh !
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.
-
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
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)
-
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.
sir ido'nt know were commandbottons i put the code please teach me!
-
sir ido'nt know were commandbottons i put the code please teach me!
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
-
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
sir I add u in FB! please acept it!
-
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
So, Can you tell us from where you copy this code?
-
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"
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[^]
-
So, Can you tell us from where you copy this code?
in my proff. this my project in 1st sem sir help me!
-
in my proff. this my project in 1st sem sir help me!
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.