Page 1 of 1

[Tut] Visual Basic 2005, Simple Program (Calculator)

Posted: Wed Apr 05, 2006 7:10 pm
by sarge derek
Addition Calculator

1. Make a new project called whatever you want

2. Add in 3 textboxes and a button

3. Name the textboxes firstbox, secondbox, and final. Name the button ADDbtn

4. Double Click your button and add the code

Code: Select all

Dim firstnumber As Integer
Dim secondnumber As Integer
Dim result As Integer
firstnumber = Firstbox.Text
secondnumber=Secondbox.Text
result = firstnumber + secondnumber
Final.Text= result
what ^^^^^ this code means is that your stating the 3 textboxes are any Integer (whole number). Then that the first integer will be what is in the first textbox then the second integer what is in the second box. Finally result states that it is simply the first two integers added together and displayed in the Final TextBox

Try making other buttons that say other mathematical functions like subtract and divide using the same concept

Posted: Wed Apr 19, 2006 10:17 pm
by dos mes
The + sign does not correctly add. It adds the 2 numbers together like this though. 1+2 = 12. Do you know what the real sign for it is? I got all of the others working though.

Posted: Thu Apr 20, 2006 4:35 am
by Patrickssj6
Dos Mes wrote:The + sign does not correctly add. It adds the 2 numbers together like this though. 1+2 = 12. Do you know what the real sign for it is? I got all of the others working though.
If you delcare it an Integer it works methink :D

Posted: Thu Apr 20, 2006 4:48 am
by Kurroda
i made a calculator the other day that looks like ms calculator

Posted: Thu Apr 20, 2006 10:59 am
by dos mes
Indeed it's cool. I would use that idea for mine but I like the new layout that i made for my app better.

Posted: Thu Apr 20, 2006 2:22 pm
by sarge derek
yea the plus adds like 1+2=12 only when its a string i think, not as integer though

Posted: Thu Apr 20, 2006 4:42 pm
by dos mes
Yea, i just didnt dim the textboxes as integers, only the result becuase I didn't think that I would need to but I got it now. Thanks.

Posted: Thu Apr 20, 2006 4:54 pm
by Patrickssj6
Dos Mes wrote:Yea, i just didnt dim the textboxes as integers, only the result becuase I didn't think that I would need to but I got it now. Thanks.
Thats would work in VB6 I think :D