Skip to main content

How to make a Calculator -(Part-4) of using Visual Basic2010


Calculator  - Visual Basic 2008 / 2010
Page 4
The Zero Button:
Double click on the zero button and add the following highlighted code:
Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
If Button1.Text = Label1.Text Then
Button1.Text = "0."
ElseIf Button1.Text = "0." Then
Button1.Text = "0."
ElseIf Button1.Text = "0" Then
Button1.Text = "0."
ElseIf Button1.Text = Label3.Text Then
Button1.Text = "0."
Else
Button1.Text = Button1.Text & "0"
End If
End Sub

The Decimal Button:
Double click on the decimal button and add the following highlighted code:
Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
If Button1.Text = "0." Then
Button1.Text = "."
ElseIf Button1.Text = Label3.Text Then
Button1.Text = "."
ElseIf Button1.Text = Label1.Text Then
Button1.Text = "."
Else
If Button1.Text.Contains(".") Then
Else
Button1.Text = Button1.Text & "."
End If

End If
End Sub
The One Button:
Double click on the one button and add the following highlighted code:
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
If Button1.Text = Label1.Text Then
Button1.Text = "1"
ElseIf Button1.Text = "0." Then
Button1.Text = "1"
ElseIf Button1.Text = Label3.Text Then
Button1.Text = "1"
Else
Button1.Text = Button1.Text & "1"
End If
End Sub
The Two Button:
Double click on the two button and add the following highlighted code:
Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
If Button1.Text = Label1.Text Then
Button1.Text = "2"
ElseIf Button1.Text = "0." Then
Button1.Text = "2"
ElseIf Button1.Text = Label3.Text Then
Button1.Text = "2"
Else
Button1.Text = Button1.Text & "2"
End If
End Sub
The Three Button:
Double click on the three button and add the following highlighted code:
Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
If Button1.Text = Label1.Text Then
Button1.Text = "3"
ElseIf Button1.Text = "0." Then
Button1.Text = "3"
ElseIf Button1.Text = Label3.Text Then
Button1.Text = "3"
Else
Button1.Text = Button1.Text & "3"
End If
End Sub
The Four Button:
Double click on the four button and add the following highlighted code:
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
If Button1.Text = Label1.Text Then
Button1.Text = "4"
ElseIf Button1.Text = "0." Then
Button1.Text = "4"
ElseIf Button1.Text = Label3.Text Then
Button1.Text = "4"
Else
Button1.Text = Button1.Text & "4"
End If
End Sub

The Five Button:
Double click on the five button and add the following highlighted code:
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
If Button1.Text = Label1.Text Then
Button1.Text = "5"
ElseIf Button1.Text = "0." Then
Button1.Text = "5"
ElseIf Button1.Text = Label3.Text Then
Button1.Text = "5"
Else
Button1.Text = Button1.Text & "5"
End If
End Sub

The Six Button:
Double click on the six button and add the following highlighted code:
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
If Button1.Text = Label1.Text Then
Button1.Text = "6"
ElseIf Button1.Text = "0." Then
Button1.Text = "6"
ElseIf Button1.Text = Label3.Text Then
Button1.Text = "6"
Else
Button1.Text = Button1.Text & "6"
End If
End Sub


The Seven Button:
Double click on the seven button and add the following highlighted code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If Button1.Text = Label1.Text Then
Button1.Text = "7"
ElseIf Button1.Text = "0." Then
Button1.Text = "7"
ElseIf Button1.Text = Label3.Text Then
Button1.Text = "7"
Else
Button1.Text = Button1.Text & "7"
End If
End Sub

The Eight Button:
Double click on the eight button and add the following highlighted code:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If Button1.Text = Label1.Text Then
Button1.Text = "8"
ElseIf Button1.Text = "0." Then
Button1.Text = "8"
ElseIf Button1.Text = Label3.Text Then
Button1.Text = "8"
Else
Button1.Text = Button1.Text & "8"
End If
End Sub

The Nine Button:
Double click on the nine button and add the following highlighted code:
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
If Button1.Text = Label1.Text Then
Button1.Text = "9"
ElseIf Button1.Text = "0." Then
Button1.Text = "9"
ElseIf Button1.Text = Label3.Text Then
Button1.Text = "9"
Else
Button1.Text = Button1.Text & "9"
End If
End Sub

The calculator is ready now and should work fine.
                       
                                           

If your calculator is working fine, you can publish it:

                                              





Comments

Popular posts from this blog

Managing a Simple Mailing List

This hour provides the first of several hands-on, small projects designed to pull together your PHP and MySQL knowledge. In this hour, you'll learn the methods for creating a managed distribution list, which can be used to send out newsletters or anything else that you want to send, to a list of email addresses in a database. The mailing mechanism you'll use in this hour is not meant to be a replacement for mailing list software, which is specifically designed for bulk messages. The type of system you'll build in this lesson should be used for only small lists of fewer than a few hundred email addresses. In this hour, you will learn how to Create a subscribe/unsubscribe form and script Create a front end for sending your message Create the script that sends your message Developing the Subscription Mechanism You learned in earlier lessons that planning is the most important aspect of creating any product. In this case, think of the element...

Joomla Video Tutorials-06

Working with Joomla Extensions     6. Joomla Content

PHP course catalogs

Introduction   In this PHP course, you will learn Advanced level PHP with CodeIgniter framework, and how to execute scripts on your server. You will also learn about MySQL, html, CSS, JavaScript. You will also learn advanced level CSS, Database Normalization & Relation of Database. After attending the course, you can develop project using PHP framework CodeIgniter with MySQL. How participants will benefit after the course:   After attending this course, participants will be able to develop professional dynamic website using PHP framework CodeIgniter, design database with proper documentation, and develop Online Payment Method. Course Highlights:   . Complete package on web development  . Advanced JavaScript & Ajax  . PHP framework along with documentation process  . Client Side & Server Side Validation  . CI Framework Reporting  . TinyMce Editor & Searching  . SSL, File upload & Email  . Online Paym...