I am making a calculator in Virtual Basic for almost a week. I am encountering a problem when using the equals sign. When I type problems like 4 + 6 = 10 it answers correctly. When I press the equal again immediately after the calculator answers 10. It should enter as 10 + 6 = 16 but it does not work like that. How do I create a calculator that when users press again and again they will have a loop of + 6? Please help me. This is the code I used for my equal sign button.
DAVE_44
0
Newbie Poster
Recommended Answers
Jump to PostYou have to adjust the value for
num1
so that the next time you click=
you get the correct answer. If you wantans
to be the sum ofnum1
andnum2
the first time, thennum2
andans
the next time, you'll have to assignans
tonum1
. …
Jump to PostAs a further note, if you see the same line of code in every if-else block, that's a good sign you should move it out of the block and put it just once at the end. You also might want to look into the
select
statement. It's a little cleaner.
All 6 Replies
DAVE_44
0
Newbie Poster
Reverend Jim
4,780
Hi, I'm Jim, one of DaniWeb's moderators.
Moderator
Featured Poster
DAVE_44
commented:
I understand what you mean but I do not know the code of that. I am sorry can you type it in Visual Basic Language?
+0
Reverend Jim
4,780
Hi, I'm Jim, one of DaniWeb's moderators.
Moderator
Featured Poster
DAVE_44
commented:
I already done this one but I cannot code the one you mentioned on the other comment
+0
DAVE_44
0
Newbie Poster
DAVE_44
0
Newbie Poster
Reverend Jim
4,780
Hi, I'm Jim, one of DaniWeb's moderators.
Moderator
Featured Poster
DAVE_44
commented:
what should be the scope of num1 for this to work? hahahaha it did not work on my code
+0
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.