Click here to Skip to main content
15,880,608 members
Articles / Programming Languages / Visual Basic

A multipurpose scientific calculator

Rate me:
Please Sign up or sign in to vote.
2.56/5 (36 votes)
17 Apr 2008CPOL5 min read 188.5K   14.2K   50  
A calculator handling complex numbers and scientific functions
��Public Class series

    Public Irange(3) As Integer

    Private Sub trign_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click

        calculator.trigfn.inv.Checked = False

        calculator.Select()

    End Sub

    Public Sub trign_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Me.BackColor = calculator.BackColor

        Me.Location = New System.Drawing.Point(calculator.Right, calculator.Bottom - Me.Height - calculator.memoryfrm.Height - calculator.trigfn.Height - calculator.engfrm.Height)

        Me.Owner = calculator

    End Sub

    Private Sub trigbut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles sadd.Click, spr.Click

        calculator.Select()

        If Not calculator.s = 0 Then

            calculator.s = 0

            calculator.expression.Clear()

            calculator.expression.Select()

        End If

        calculator.expression.Paste(sender.text)

        calculator.trigfn.inv.Checked = False

    End Sub



    Private Sub trign_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint

        Me.Location = New System.Drawing.Point(calculator.Right, calculator.Bottom - Me.Height - calculator.memoryfrm.Height - calculator.trigfn.Height - calculator.engfrm.Height)

    End Sub

    Private Sub sel(ByVal sender As Object, ByVal e As System.EventArgs) Handles spr.Click, Me.Click, sadd.Click, I.Click

        If calculator.s = 0 Then

            calculator.expression.Select()

        End If

        calculator.comment.Text = ""

    End Sub

    Private Sub trign_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown

        calculator.Select()

    End Sub



    Private Sub I_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles I.Click

        If Setlv.Checked Then

            If calculator.expression.TextLength = 0 Then

                Return

            End If

            calculator.eqls.PerformClick()

            Setlv.Checked = False

            Try

                Irange(0) = Convert.ToInt32(calculator.value.Text)

            Catch ex As Exception

                calculator.comment.Text = "Invalid assignment"

                Return

            End Try

            Return

        End If

        If Sethv.Checked Then

            If calculator.expression.TextLength = 0 Then

                Return

            End If

            calculator.eqls.PerformClick()

            Sethv.Checked = False

            Try

                Irange(1) = Convert.ToInt32(calculator.value.Text)

            Catch ex As Exception

                calculator.comment.Text = "Invalid assignment"

                Return

            End Try

            Return

        End If

        calculator.Select()

        If Not calculator.s = 0 Then

            calculator.s = 0

            calculator.expression.Clear()

            calculator.expression.Select()

        End If

        calculator.expression.Paste(sender.text)

        calculator.trigfn.inv.Checked = False

    End Sub



    Private Sub Sethv_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Sethv.Click

        Setlv.Checked = False

    End Sub



    Private Sub Setlv_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Setlv.Click

        Sethv.Checked = False

    End Sub

End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Technical Lead Yahoo!
India India
I've studied info. sc. engg. from Sir MVIT, Bangalore.

I'm interested in programming.

Some of my technical blogs:

http://perl-blog.kbsbng.com/
http://java-blog.kbsbng.com/

I also enjoy writing some webpages such as http://sites.google.com/site/plantencyclopedia/

More about me at http://www.kbsbng.com and http://blog.kbsbng.com.

Comments and Discussions