Calculator in VB with splash screen

No.of Views2612
Bookmarked2 times
Downloads 
Votes3
By  NikhilJohari   On  22 Jul 2010 06:07:42
Tag : Visual Basic 6.0 , Windows Forms
In this article,i have share with you, create Calculator in VB with splash screen.
emailbookmarkadd commentsprint

Images in this article missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at info@codegain.com

 

Introduction

In this article,i have share with you, create Calculator in VB with splash screen.This calculator do all basic calculation operation.First i have created a splash screen to load calculator settings. 

Image Loading

Figure 1: Splash Screen

Code for the Splash Screen

Before write code, we have to add Timer Control into project. then ,

Public Class Form1Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Timer1.Enabled = TrueEnd SubPrivate Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        ProgressBar1.Increment(1)If ProgressBar1.Value = ProgressBar1.Maximum Thencalculator.Show()
            Timer1.Stop()Me.Hide()End IfEnd SubEnd Class

 Now i have desgined Calculator form with textboxs and button, like followings, 

Image Loading

Figure 2: Main Calculator

Now i have write code for calculator.here is code

Option Explicit OnPublic Class calculatorPublic diff_x As IntegerPublic diff_y As IntegerPublic mouse_down As Boolean = False'Declarationg for movableFormDim FirstNumber As SingleDim SecondNumber As SingleDim AnswerNumber As SingleDim Arithimetic As String‘Closing ButtonPrivate Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickMe.Close()End Sub 

‘.ButtonPrivate Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
        txtDisplay.Text = txtDisplay.Text & "."End Sub0 ButtonPrivate Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        txtDisplay.Text = txtDisplay.Text & "0"End Sub1 ButtonPrivate Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
        txtDisplay.Text = txtDisplay.Text & "1"End SubPrivate Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
        txtDisplay.Text = txtDisplay.Text & "2"End SubPrivate Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        txtDisplay.Text = txtDisplay.Text & "3"End SubPrivate Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        txtDisplay.Text = txtDisplay.Text & "4"End SubPrivate Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        txtDisplay.Text = txtDisplay.Text & "5"End SubPrivate Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        txtDisplay.Text = txtDisplay.Text & "6"End SubPrivate Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        txtDisplay.Text = txtDisplay.Text & "7"End SubPrivate Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        txtDisplay.Text = txtDisplay.Text & "8"End Sub9 ButtonPrivate Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        txtDisplay.Text = txtDisplay.Text & "9"End Sub‘Clear ButtonPrivate Sub Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button18.Click
        txtDisplay.Text = "0"End Sub‘+ ButtonPrivate Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
        FirstNumber = Val(txtDisplay.Text)
        txtDisplay.Text = "0"Arithimetic = "+"End Sub‘-Button    
Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
        FirstNumber = Val(txtDisplay.Text)
        txtDisplay.Text = "0"Arithimetic = "-"End Sub‘ * ButtonPrivate Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click
        FirstNumber = Val(txtDisplay.Text)
        txtDisplay.Text = "0"Arithimetic = "*"End Sub‘/ Button   
Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button17.Click
        FirstNumber = Val(txtDisplay.Text)
        txtDisplay.Text = "0"Arithimetic = "/"End Sub‘ = ButtonPrivate Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
        SecondNumber = Val(txtDisplay.Text)If Arithimetic = "+" ThenAnswerNumber = FirstNumber + SecondNumberEnd IfIF Arithimetic = "-" ThenAnswerNumber = FirstNumber - SecondNumberEnd IfIf Arithimetic = "*" ThenAnswerNumber = FirstNumber * SecondNumberEnd IfIf Arithimetic = "/" ThenAnswerNumber = FirstNumber / SecondNumberEnd IftxtDisplay.Text = AnswerNumberEnd Sub‘ Form Events to make it movable.Private Sub calculator_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
        diff_x = Form.MousePosition.X - Form.ActiveForm.Location.X
        diff_y = Form.MousePosition.Y - Form.ActiveForm.Location.Y
        mouse_down = TrueEnd SubPrivate Sub calculator_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseUp
        mouse_down = FalseEnd SubPrivate Sub calculator_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMoveIf mouse_down = True ThenDim p As New Point(MousePosition.X - diff_x, MousePosition.Y - diff_y)
            Form.ActiveForm.Location = pEnd IfEnd SubEnd Class

 That's all, i hope this article help to you all. thank you happy coding.Any help needed just ask me ignitesofthelp@gmail.com

 
Sign Up to vote for this article
 
About Author
 
NikhilJohari
Occupation-
Company-
Member Type-Senior
Location-India
Joined date-15 Aug 2009
Home Page-http://fast-get.com
Blog Page-http://dotnetask.blog.co.in
 
 
Other popularSectionarticles
    Comments
    By:NikhilDate Of Posted:7/25/2010 9:40:43 AM
    Nik
    Thanks !!! i will try my best...
    By:RRaveenDate Of Posted:7/23/2010 11:04:11 AM
    Great work
    This is small and good work by you.we are looking more application.
    Leave a Reply
    Title:
    Display Name:
    Email:
    (not display in page for the security purphase)
    Website:
    Message:
    Please refresh your screen using Ctrl+F5
    If you can't read this number refresh your screen
    Please input the anti-spam code that you can read in the image.
    ^ Scroll to Top
    </