Basic Calculator Tutorial in Visual Basic .NET

Tags: VB.NET, VB 2008, VB 2010, VB 2012, VB 2013

This tutorial will show you how to make a basic calculator in visual basic .net.

Source Code for the calculator project is available at the end of page 3 of this tutorial.

Create a new project.
You can change the form text to "your name's calculator". Click on the form and then go to properties window, then change the text property.
You also need to disable the maximize control of the form. That's because you don't want the user to maximize the calculator. Go to the properties window, and change the maximize box property to False:

start a calculator tutorial in visual basic

You also need to change the FormBorderStyle property to Fixed3D

change calculator form property in vb.net

Add a button to the form and place on top of the form:

Visual Basic 2008 Calculator

You might be surprised of this button because we should have placed a textbox instead. Well, this is the cool thing about Visual Basic, you can use a button to display text and results.
Now we have to change the button properties to look like a text box.
First we change it's text to "0.".

add button to vb calculator

We align the text to be on the right. Right click on the button, click on properties. In the properties window change TextAlign to MiddleRight:

Visual Basic 2008 Calculator

Choose the box in the middle right (the blue one in the image above)

Change the FlatStyle of the button. In the properties window change FlatStyle to Flat:

Visual Basic 2008 Calculator

You also need to change the color of the button. Go to the properties window and change the backcolor property to white:

Visual Basic 2008 Calculator

There are two more properties you need to change: TabStop to False and Enabled to False.

Visual Basic 2008 Calculator

Your button should look like this now:

Visual Basic 2008 Calculator

Page: 1 2 3


Share This

Home | About | Contact | Privacy Policy

Copyright visual-basic-tutorials.com 2014 - All Rights Reserved.