News:

Build a stunning handcrafted website with IT Acumens

Main Menu

A Calculator Project in VB Net

Started by sukishan, Jul 11, 2009, 06:18 PM

Previous topic - Next topic

sukishan

VB Net Calculator

Designing the Form
Let's design the form first. What does a calculator need? Well numbers, for one. A display area for the result. A plus sign button, an equals sign button, and a clear the display button.

Here's how our calculator is going to work. We'll have 10 button for the numbers 0 to 9. When a button is clicked its value will be transferred to a display area, which will be a Textbox. Once a number is transferred to the Textbox we can click on the Plus button. Then we need to click back on another number. To get the answer, we'll click on the equals sign. To clear the display, we'll have a Clear button.

If you haven't already, create a new project. Save it as Calculator. To your new form, first add ten Buttons (You can add one, then copy and paste the rest). The Buttons should have the following Properties:

Name: btn Plus a Number (btnOne, btnTwo, btnThree, etc)

Text: A number from 0 to 9. A different one for each button, obviously

Font: MS Sans Serif, Bold, 14

Next, add a Textbox. Set the following properties for the Textbox:

Textbox
Name: txtDisplay
Font: MS Sans Serif, Bold, 14
Text: Erase the default, Textbox1, and leave it blank

Three more Command buttons need to be added
Plus Button
Name cmdPlus
Font MS Sans Serif, Bold, 14
Text +

Equals Button
Name cmdEquals
Font MS Sans Serif, Bold, 14
Text =

Clear Button
Name cmdClear
Font MS Sans Serif, Bold, 14
Text Clear

When your form design is finished, it might look something like this:

So if you wanted to add 5 + 9, you would click first on the 5. A 5 would appear in the textbox. Then you would click the + symbol. The 5 would disappear from the textbox. Next, click on the 9. The number 9 would appear in the textbox. Finally, click on the = symbol. The 9 would disappear from the textbox, and the answer to our sum would replace it. We would then click the Clear button to clear the display.
A good beginning makes a good ending

pradeep prem

its easy to use this program

the calculator program to use this in vb.net

but it has big program easy to solve

Gurbani Kaur

GyanDhan has a tool known as EMI Calculator to help students in assessing the EMI of their education loan. https://www.gyandhan.com/education-loan-emi-calculator