Well you would have to recode some of your program to make it work for an equals button.. the only reason it works for addition is because you're basically performing the addition twice.
Give me a few minutes and I'll try to write up some code that'll have an equals button.
Edit: Try this code.. I don't know if it works because I don't have visual basic installed but it should work. It will only work for 2 numbers. Make sure your equals button is named "Button5"
Code:Dim firstValue as Double Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click firstValue = Val(TextBox1.Text) Label2.Text = "-" End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click firstValue = Val(TextBox1.Text) Label2.Text = "+" End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click firstValue = Val(TextBox1.Text) Label2.Text = "x" End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click firstValue = Val(TextBox1.Text) Label2.Text = "/" End Sub Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click Label2.Text = "=" Label1.Text = firstValue / Val(TextBox2.Text) End Sub
Last edited by ShawnjohnSJ; 02-03-2012 at 06:09 PM.
TextBox2.Text is a variable. When you do Val(TextBox2.Text) it converts that string into an integer (hence Val=Value).. what you're doing here is setting the integer value of TextBox2.Text to ... which doesn't make any sense.
To put that into simpler terms, only use Val after the equals sign.
Code:TextBox2.Text = Val(TextBox5.Text) - Val(TextBox4.Text) * Val(TextBox6.Text)
I agree with Wizzup?, he is a B O S S btw.
If you want to learn any programming, start with basic or pascal!
For the basics of the basics of pascal, try my TuT. ||Photoshop Editing ||MapleResourceDung Script || Book a flight! BuySellTrip
True, the syntax is very different and the idea of event-driven programming gets you into a completely different mindset than if you were programming in C++, Java, etc. What I meant by it being a good language for starters is not having to mess around with creating the code for GUI's (which can be daunting sometimes) and easy manipulation of components on the GUI. Its very easy for someone to jump right in and create a calculator (for example) and learn about variables, expressions, methods, etc. But everyone has different opinions and preferences, I guess its just a matter of where you feel comfortable starting off at.
You may contact me with any concerns you have.
Are you a victim of harassment? Please notify me or any other staff member.
| SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |
I've had a little practice with it and want to make a Runescape Calculator of some sort, but what should I make?
You may contact me with any concerns you have.
Are you a victim of harassment? Please notify me or any other staff member.
| SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |
There are currently 1 users browsing this thread. (0 members and 1 guests)