Easy Peasy Calculator

Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
7 posts Page 1 of 1
Contributors
User avatar
hungryhounduk
VIP - Site Partner
VIP - Site Partner
Posts: 2870
Joined: Mon Jul 27, 2009 11:58 am

Easy Peasy Calculator
hungryhounduk
Hi All Here is a very Easy Peasy Tutorial for making your Own Calculator

Image

On the Form you will need

1 Textbox
17 Buttons

All the code for this tutorial is below

This goes above "Public Class Form1"
Code: Select all
Option Explicit On

This Goes below "Public Form1"
Code: Select all
Dim FirstNumber As Single
Dim SecondNumber As Single
Dim AnswerNumber As Single
Dim ArithmeticProcess As String
Button (1)
Code: Select all
txtDisplay.Text = txtDisplay.Text & 1

Button (2)
Code: Select all
txtDisplay.Text = txtDisplay.Text & 2

Button (3)
Code: Select all
txtDisplay.Text = txtDisplay.Text & 3

Button (4)
Code: Select all
txtDisplay.Text = txtDisplay.Text & 4

Button (5)
Code: Select all
txtDisplay.Text = txtDisplay.Text & 5

Button (6)
Code: Select all
txtDisplay.Text = txtDisplay.Text & 6

Button (7)
Code: Select all
txtDisplay.Text = txtDisplay.Text & 7

Button (8)
Code: Select all
txtDisplay.Text = txtDisplay.Text & 8

Button (9)
Code: Select all
txtDisplay.Text = txtDisplay.Text & 9

Decimal Point Button
Code: Select all
txtDisplay.Text = txtDisplay.Text & "."

Clear Button
Code: Select all
txtDisplay.Text = "0"

Add Button
Code: Select all
FirstNumber = Val(txtDisplay.Text)
txtDisplay.Text = "0"
ArithmeticProcess = "+"

Equals Button
Code: Select all
SecondNumber = Val(txtDisplay.Text)
If ArithmeticProcess = "+" Then
AnswerNumber = FirstNumber + SecondNumber
End If
If ArithmeticProcess = "-" Then
AnswerNumber = FirstNumber - SecondNumber
End If
If ArithmeticProcess = "X" Then
AnswerNumber = FirstNumber * SecondNumber
End If
If ArithmeticProcess = "/" Then
AnswerNumber = FirstNumber / SecondNumber
End If
txtDisplay.Text = AnswerNumber

Minus Button
Code: Select all
FirstNumber = Val(txtDisplay.Text)
txtDisplay.Text = "0"
ArithmeticProcess = "-"

Multiply Button
Code: Select all
FirstNumber = Val(txtDisplay.Text)
txtDisplay.Text = "0"
ArithmeticProcess = "X"

Divide Button
Code: Select all
FirstNumber = Val(txtDisplay.Text)
txtDisplay.Text = "0"
ArithmeticProcess = "/"
Chris
Image
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4392
Joined: Tue Aug 04, 2009 1:47 am

Re: Easy Peasy Calculator
CodenStuff
Hello hungryhounduk,

I realy love the 3d look of this calculator, your still surprising me day after day ;) .

Excellent work keep it up cooll;

Ive never tried to do a calculator in VB before so this is something new for me to play with :D
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
hungryhounduk
VIP - Site Partner
VIP - Site Partner
Posts: 2870
Joined: Mon Jul 27, 2009 11:58 am

Re: Easy Peasy Calculator
hungryhounduk
Hi
Its Just a little ditty i knocked up to do the tutorial with :)

Calculators are quite fun

Chris
Image
User avatar
CodemaN
VIP Access - Denied
VIP Access - Denied
Posts: 74
Joined: Fri Sep 18, 2009 3:18 pm

Re: Easy Peasy Calculator
CodemaN
coollll thanksssssssss wahooo; wahooo;
User avatar
Usman55
VIP - Site Partner
VIP - Site Partner
Posts: 2821
Joined: Thu Dec 24, 2009 7:52 pm

Re: Easy Peasy Calculator
Usman55
Hello Hungryhounduk!

I have also made a calculator (without a skin) (with more features) which I will be posting soon!

Thanks for the skin!!!!!
Image
Lewis
Coding God
Coding God
Posts: 1564
Joined: Sun Dec 20, 2009 2:12 pm

Re: Easy Peasy Calculator
Lewis
I like th skin aswell :D
Image
User avatar
35000vr
Top Poster
Top Poster
Posts: 176
Joined: Sat Mar 06, 2010 5:09 pm

Re: Easy Peasy Calculator
35000vr
I Love The Skiiiiiiin
‼ <----- Copy it,it is together and if you backspace it it will both erase
☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !"<-----Some Cool symbols.
♂<-----Boy Symbol :)
²ƽ<--------Mini 2 and 5!
ð<----Not sure what it is.
☺☻<-----Smiles
♪♫<----Music Notes
Others:ß┬ƒ○║■ã¿┼↑
7 posts Page 1 of 1
Return to “Tutorials”