|
-
Apr 18th, 2013, 04:46 AM
#1
Thread Starter
Junior Member
Calculator problem !
Hey I am new to Visual basic, I learnt some things and I want to make a calculator I want it with buttons so I made the 9 buttons of the 9 numbers and I made 2 labels what I actually want is when I press Button "1" label = "1" then I press button "6" the next label be = "6" so I made this:
Private Sub num3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles num3.Click
If Number2.Text = Nothing Then
Number2.Text = "3"
End If
Number1.Text = "3"
End Sub
and it's not working can someone help me please?
-
Apr 18th, 2013, 08:26 AM
#2
Re: Calculator problem !
You might try elaborating on "not working" by explaining exactly what you expect to see and exactly what you do see. That said, presumably you want an If...Else statement because you only want one or the other to be executed.
-
Apr 18th, 2013, 08:39 AM
#3
-
Apr 18th, 2013, 08:51 AM
#4
Thread Starter
Junior Member
Re: Calculator problem !
okay what I actually want:
I want when I press button1 it appears on label1 "1" then I press button5 so it appears on label2 "5"
I tried a lot of times but when I press button1 it appeares on label1 "1" then I press button5 it appears on the same label1 "5"
-
Apr 18th, 2013, 01:52 PM
#5
Re: Calculator problem !
if you set the label's text property equal to the number, then wouldn't you expect to be only contain that number? Rather than appending the number? It is possible to set the text property equal to itself with the additon of other text appended or prepended.
-
Apr 18th, 2013, 06:32 PM
#6
Re: Calculator problem !
 Originally Posted by Youssef
okay what I actually want:
I want when I press button1 it appears on label1 "1" then I press button5 so it appears on label2 "5"
I tried a lot of times but when I press button1 it appeares on label1 "1" then I press button5 it appears on the same label1 "5"
As I said in my first replay, you need to use an If...Else statement. In the code you posted you are testing a condition and performing one task if it is True, then performing another task regardless. You need to perform one task if the condition is True and the other task if it's False, which is exactly what an If...Else statement does.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|