How To Make A Calculator In Visual Basic 2008 / Visual Basic 2010

Today i will teach you how to make a calculator in VB.NET , making your own calculator would be awesome.
  1. open visual basic 2008 or visual basic 2010
  2. create a new project
  3. windows form/console application
  4. change your form size to 223, 274
  5. go to form1 properties and text name it whatever you want (calculator)
  6. add 18 buttons from the tool box
  7. add a textbox
  8. click textbox then properties and multiline and make it true
  9. click text box and properties and click font and make the font little bigger
  10. make the text box little bigger
  11. now change the button text to look like this
12 .now double click the form and delete everything

13 . then copy and paste this bunch of code

Option Explicit On
Public Class Form1
 
    'Author : Mohamed Shimran
 
    Dim FirstNumber As Single
    Dim SecondNumber As Single
    Dim AnswerNumber As Single
    Dim ArithmeticProcess As String
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TextBox1.Text = TextBox1.Text & 1
    End Sub
 
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TextBox1.Text = TextBox1.Text & 2
    End Sub
 
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        TextBox1.Text = TextBox1.Text & 3
    End Sub
 
    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        TextBox1.Text = TextBox1.Text & 4
    End Sub
 
    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        TextBox1.Text = TextBox1.Text & 5
    End Sub
 
    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        TextBox1.Text = TextBox1.Text & 6
    End Sub
 
    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        TextBox1.Text = TextBox1.Text & 7
    End Sub
 
    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        TextBox1.Text = TextBox1.Text & 8
    End Sub
 
    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        TextBox1.Text = TextBox1.Text & 9
    End Sub
 
    Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
        TextBox1.Text = TextBox1.Text & 0
    End Sub
 
    Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
        TextBox1.Text = TextBox1.Text & "."
    End Sub
 
    Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
        FirstNumber = Val(TextBox1.Text)
        TextBox1.Text = "0"
        ArithmeticProcess = "+"
    End Sub
 
    Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
 
 
        FirstNumber = Val(TextBox1.Text)
        TextBox1.Text = "0"
        ArithmeticProcess = "-"
    End Sub
 
    Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
        FirstNumber = Val(TextBox1.Text)
        TextBox1.Text = "0"
        ArithmeticProcess = "X"
    End Sub
 
    Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click
        FirstNumber = Val(TextBox1.Text)
        TextBox1.Text = "0"
        ArithmeticProcess = "/"
    End Sub
 
  
    Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button18.Click
        SecondNumber = Val(TextBox1.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
        TextBox1.Text = AnswerNumber
    End Sub
 
End Class
13 . now debug

14. enjoy

I did a tutorial about making an advanced calculator, you would love it : How To Make A Advance Calculator In VB.NET

44 comments

Not working, it says that (Error 1 Handles clause requires a WithEvents variable defined in the containing type or one of its base types. C:\Users\Owner\Documents\Visual Studio 2010\Projects\Calculator\Calculator\Form1.vb 79 100 Calculator
) What do I do? Please Help? :(

Reply

i think that is a simple error , if you just create a new project and try this again then this will work you can also try this advanced calculator

Reply

Nice tutorial

Reply

GREATE WORK I LOVE VB AND YOU INSPIRE ME TO DEVELOPS VB PROJECTS VISIT MY SITE AND GET MORE STUFFS CLICK HERE http://premtrivedi.blogspot.in/

Reply

Doesn't work for me i don't know why

Reply

What kind of errors you get? by the way if you don't mind theres another calculator little bit advanced, check Here

Reply

hey i keep getting identified expected ? any chance i can fix that?

Reply

sorry figured that out its the last part saying my first number is not declaired then arithmamatic not decalired
im sorry im computer illitarit

Reply

Great tutorial, i've been looking around on how to start programming. Thank you

Reply

how is there 18 buttons i counted 16 im really confused and i'm new to VB

Reply

every time i do 2 + 2 or something it just says 0 i dont know why

Reply

i am getting 1+2+3=5 instead of 6 pls pls pls help....its urgent

Reply

It's a pretty old tutorial, Maybe you could checkout the new one : http://ultimateprogrammingtutorials.blogspot.com/2013/02/how-to-make-advance-calculator-in-vbnet.html

Reply

Hello friends.........I have also searched for good tutorial on making calculator.

Best working solution i have found here :-
http://geeksprogrammings.blogspot.com/2013/09/make-calculator-in-net.html

free Download Project is also availiable with good explantion

Reply

I nlike the appropriate answer......

Reply

This Is So Boring i Preffer making a porn site
LOL

Reply

All of the answer is 0 like
1+1 = 0
2+4 = 0
Please help me !!!

Reply

Very Nice Tutorial I like it

Reply

it dose not work noob

Reply

Yeah not working everything and the codes number has been skipped 11 then 13 then 18 do you know how to count

Reply

You need to create those items before you enter the code =P

Reply

You need to create those items before you enter the code =P

Reply

Thank you for the source code .it assisted me alot. Kudos

Reply

Echaba de menos un replicas relojes grande y voluminoso de Breitling para Bentley, del tipo que te apetece llevar una roca en la muñeca. Recientemente me dieron un Breitling Bentley Supersports réplica reloj y tengo la revisión para mostrar a you.One de Breitling para Bentley no es tan popular modelo es el Supersports. Voy a tomar una conjetura salvaje aquí y "culpar" a los colores. De alguna manera siento que la mayoría de los hombres no están en los replicas rolex con colores llamativos. Por supuesto que esto se traducirá en el mismo tipo de preferencias en el mundo de relojes Bretiling réplica. Así que estamos mirando bastante a un modelo de Bretiling falso con una popularidad y un interés medios.

Comprar Breitling réplica de relojes en línea le
replicas breitling ofrece una buena experiencia. Esta vez fui para una réplica de reloj Bentley Supersports. Me gusta el dial diferente con esos tres cronógrafos que son la marca registrada para este modelo de Bentley. Este sub-modelo en particular no está entre los sub-modelos más populares entre los
replicas omega, pero las diferentes miradas podrían funcionar bien.

Reply

Ossas

Reply

so very simple Easy ka..

Reply

In particolare, Baselworld ha fornito a Vector l’opportunità per replica orologi presentare i suoi due modelli di smartwatch – il Luna e il Meridien. Se siete appassionati del genere, sarete Tag Heuer replica felici di sapere che arriveranno sul mercato a settembre di quest’anno.

Reply

Very helpful tutorial. Thank you.

Reply

awesome post.Thanks for sharing.
Vuescan Crack

Reply

In this era SAP Training is most useful web language for web development program. A variety of businesses that make use of SAP Training web language solutions or connected services are able to combine their systems in a superior & quicker way & also offer information almost anytime & anyplace on any given device.
SAP Training Institute in Noida
sap training in noida
sap institute in noida
sap course in noida
best sap training institute in noida

Reply

Very nice and helpful post. Waiting for your next article. Thank you.

Reply

Very nice and helpful post. Waiting for your next article. Thank you.

Reply

thank you, I read and always read the article on this website

Reply

Thanks for sharing the information.Impressive and i would like to share this with my friends
Indian Cyber Army’s most awaited internship is live now. Summer Internship 2018 on “ Ethical hacking” and book your seats before it runs out.Candidates have to get themselves registered to be a part of this Internship program. Here internship will give you on-the-job experience, help you learn whether you and Cyber security industry are a good match and can provide you with valuable connections and references. Here interns are usually exposed to a wide variety of tasks and responsibilities which allows the intern to showcase their strengths by working on projects for various managers that work on different parts of Indian Cyber Army. Becoming a high performing intern is a fantastic way to improve your employment prospects. This internship can be a great way to get your foot in the door of success with a prestigious or desirable Organization.As career in ethical hacking is most in demand.

Reply

Get to know about career in Ethical Hacking. Career Overview, Salary, Key skills and Education needed. Get how to Become Ethical Hacker guidelines ...

Reply

In this age of Technology advancement, computer and information technology have not only brought convenience to citizens in modern life but also for policemen & various Government officials of the nation to fight cybercrime through various modus operandi. Indian Cyber Army has been dedicated in fighting cyber crime, striving to maintain law and order in cyberspace so as to ensure that everyone remains digitally safe.Read more:- Information Security

Reply

Post a Comment

Note: Only a member of this blog may post a comment.