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

Post here about scripting and programming for HaloPC (audio, network, ai, etc.)
Post Reply
sarge derek





Posts: 60
Joined: Wed Feb 15, 2006 7:59 pm

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

Post 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
Xlink Name: -KyA-Sgt-D, lets play some mods or mlg :)
User avatar
dos mes





Posts: 2158
Joined: Thu Dec 29, 2005 9:58 pm
Location: Syracuse, NY

Post 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.
Patrickssj6




Pi Collaborator

Posts: 5426
Joined: Sat Jul 24, 2004 12:12 pm
Location: I'm a Paranoid
Contact:

Post 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
...left for good
Kurroda





Posts: 1737
Joined: Sat Sep 03, 2005 10:01 am
Contact:

Post by Kurroda »

i made a calculator the other day that looks like ms calculator
Image
User avatar
dos mes





Posts: 2158
Joined: Thu Dec 29, 2005 9:58 pm
Location: Syracuse, NY

Post 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.
sarge derek





Posts: 60
Joined: Wed Feb 15, 2006 7:59 pm

Post by sarge derek »

yea the plus adds like 1+2=12 only when its a string i think, not as integer though
Xlink Name: -KyA-Sgt-D, lets play some mods or mlg :)
User avatar
dos mes





Posts: 2158
Joined: Thu Dec 29, 2005 9:58 pm
Location: Syracuse, NY

Post 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.
Patrickssj6




Pi Collaborator

Posts: 5426
Joined: Sat Jul 24, 2004 12:12 pm
Location: I'm a Paranoid
Contact:

Post 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
...left for good
Post Reply