Thursday, January 23, 2014

An Application Package on Data Encryption and Decryption ~~ VisualBasic Code Snippet + GUI Design

In cryptography, a substitution cipher is a method of  encoding by which units of plaintext are replaced with ciphertext, according to a regular system; the "units" may be single letters (the most common), pairs of letters, triplets of letters, mixtures of the above, and so forth. The receiver deciphers the text by performing an inverse substitution.
There are a number of different types of substitution cipher. If the cipher operates on single letters, it is termed a simple substitution cipher; a cipher that operates on larger groups of letters is termed polygraphic. A monoalphabetic cipher uses fixed substitution over the entire message, whereas a polyalphabetic cipher uses a number of substitutions at different positions in the message, where a unit from the plaintext is mapped to one of several possibilities in the ciphertext and vice versa. http://en.wikipedia.org/wiki/Substitution_cipher

** Click here for 3DES (Data Encryption & Decryption)

Shown below is the screen shot and source code for each module respectively of a data encryption and decryption system using simple substitution cipher.

Screen shot for 'Start Page'
-----------------------------

















Source code for 'Start Page'
-----------------------------
Public Class Start_Page

    Private Sub encrypt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles encrypt.Click
        frmEncrypt.ShowDialog()
    End Sub

    Private Sub Start_Page_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
        Me.Height = 357
        Me.Width = 634
    End Sub

    Private Sub decrypt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles decrypt.Click
        frmDecrypt.ShowDialog()
    End Sub

    Private Sub exitt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitt.Click
        Me.Close()
    End Sub


End Class


Screen shot for 'frmEncrypt'
-----------------------------
















Source code for 'frmEncrypt'
-----------------------------
Public Class frmEncrypt

    Private Sub cmdopen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdopen.Click
        ofd.ShowDialog()
        txtfilename.Text = ofd.FileName

        Try
            txtoriginal.Text = My.Computer.FileSystem.ReadAllText(ofd.FileName)
        Catch ex As Exception  ' Bad practice (catching exception)
            Dim a As String
            a = MessageBox.Show("File not found, Check the file name and try again", "Encryption", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            cmdopen.Focus()
            txtfilename.Text = String.Empty
        End Try
    End Sub

    Private Sub cmdsaveencrypt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdsaveencrypt.Click
        If txtEncrypted.Text = String.Empty Then
            Dim a As String
            a = MessageBox.Show("File not found; Check to make sure the file has been encrypted", "Encryption", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            cmdopen.Focus()
        Else

            Dim inn As String
            inn = InputBox("Enter file name")

            If inn = "" Then

            Else
                System.IO.File.WriteAllText("'" & inn & " ' ", txtEncrypted.Text)

                Dim haha As String
                haha = MessageBox.Show("File saved", "Encryption", MessageBoxButtons.OK, MessageBoxIcon.Information)
                txtEncrypted.Text = String.Empty
                txtoriginal.Text = String.Empty
                txtfilename.Text = ""

            End If
          End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdencrypt.Click
        Try
            txtEncrypted.Text = My.Computer.FileSystem.ReadAllText(ofd.FileName).ToLower.Replace("a", "/").Replace("b", "\").Replace("c", "*").Replace("d", "-").Replace("e", "+").Replace("f", "^").Replace("g", "<").Replace("h", ">").Replace("i", "!").Replace("j", "~").Replace("k", "@").Replace("l", "#").Replace("m", "$").Replace("n", "%").Replace("o", "&").Replace("p", "(").Replace("q", ")").Replace("r", "{").Replace("s", "}").Replace("t", "[").Replace("u", "]").Replace("v", "=").Replace("w", "'").Replace("x", "`").Replace("y", ";").Replace("z", ":").Replace("1", "|").Replace("2", "_")

            '-------substitution area--a.k.a replacement cipher------
       
        Catch ex As Exception
            Dim w As String
            w = MessageBox.Show("Check to make sure a file is selected", "Encryption", MessageBoxButtons.OK, MessageBoxIcon.Information)
            cmdopen.Focus()
        End Try
    End Sub
  
    Private Sub cmdclose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdclose.Click
        Me.Close()
    End Sub

    Private Sub frmEncrypt_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
        Me.Height = 534
        Me.Width = 970
    End Sub

    Private Sub cmdclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdclear.Click
        txtoriginal.Text = ""
        txtEncrypted.Text = ""
        txtfilename.Text = ""
        cmdopen.Focus()
    End Sub

    Private Sub frmEncrypt_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class

Screen shot for 'frmDecrypt'
-----------------------------

















Source code  for 'frmDecrypt'
-----------------------------
Public Class frmDecrypt

    Private Sub cmdopen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdopen.Click

        Try
            OpenFileDialog1.ShowDialog()
            txtfilename.Text = OpenFileDialog1.FileName
            txtoriginal.Text = My.Computer.FileSystem.ReadAllText(OpenFileDialog1.FileName)
        Catch ju As Exception
            Dim viva As String
            viva = MessageBox.Show("No file selected", "Decryption", MessageBoxButtons.OK, MessageBoxIcon.Information)
            cmdopen.Focus()
            txtfilename.Clear()

        End Try
    End Sub

    Private Sub cmddecrypt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmddecrypt.Click
        If txtoriginal.Text = "" Then
            Dim viv As String
            viv = MessageBox.Show("No file selected for decryption", "Decryption", MessageBoxButtons.OK, MessageBoxIcon.Information)

        Else
            txtdecrypted.Text = My.Computer.FileSystem.ReadAllText(OpenFileDialog1.FileName).ToLower.Replace("/", "a").Replace("\", "b").Replace("*", "c").Replace("-", "d").Replace("+", "e").Replace("^", "f").Replace("<", "g").Replace(">", "h").Replace("!", "i").Replace("~", "j").Replace("@", "k").Replace("#", "l").Replace("$", "m").Replace("%", "n").Replace("&", "o").Replace("(", "p").Replace(")", "q").Replace("{", "r").Replace("}", "s").Replace("[", "t").Replace("]", "u").Replace("=", "v").Replace("'", "w").Replace("`", "x").Replace(";", "y").Replace(":", "z").Replace("|", "1").Replace("_", "2")
            '--.....decryption arena....don't touch--------------------------------
        End If
    End Sub

    Private Sub cmdexit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdexit.Click
        Me.Close()
    End Sub

    Private Sub frmDecrypt_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
        Me.Height = 534
        Me.Width = 970
    End Sub

    Private Sub cmdsavedecrypt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdsavedecrypt.Click
        If txtdecrypted.Text = String.Empty Then
            Dim a As String
            a = MessageBox.Show("File not found", "Decryption", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            cmdopen.Focus()
        Else
            Dim oops As String
            oops = InputBox("Enter file name")

            If oops = "" Then
' Do nothing
            Else
                System.IO.File.WriteAllText("'" & oops & " ' ", txtdecrypted.Text)

                Dim ha As String
                ha = MessageBox.Show("File saved", "Decryption", MessageBoxButtons.OK, MessageBoxIcon.Information)
                txtdecrypted.Text = String.Empty
                txtoriginal.Text = String.Empty
                txtfilename.Text = ""
                'GoTo k
            End If
        End If
    End Sub

    Private Sub btnclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnclear.Click
        txtoriginal.Text = ""
        txtdecrypted.Text = ""
        txtfilename.Text = ""
        cmdopen.Focus()
    End Sub
End Class
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Click here for Tripple DES (Data Encryption & Decryption)
============================================

Friday, January 17, 2014

An Application Package on Electronic Voting System (EVS) ~~ VisualBasic & SQL Server Code Snippet + GUI Design

First, i would like to say "Happy Newest year to you; yes! you". Haven't seen my new year gift yet? simply run the below java code AND boOOOomm! you would see/receive it.

import javax.swing.JOptionPane;     
class HappyNewYear
{
           String sMessage = "** Happy New Year!!!!!!!! **";

          HappyNewYear()
        {
          JOptionPane.showMessageDialog(null, sMessage);
         }
     public static void main(String [] args)
     {
            new HappyNewYear();
     }
}

Ok, back to business;
Electronic voting, also known as e-voting is a term encompassing several types of voting, embracing both electronic means of casting a vote and electronic means of counting votes ~> http://en.wikipedia.org/wiki/Electronic_voting ; Modules/Screen shots used in the design of  this system are as follows:

Login Screen: - Because this package is designed using Nigeria as a case study, Independent national electoral commission {inec} officials are expected to login into the system using their individual login details.



Finger Print Authentication Screen: - to cast your vote, voter(s) is/are expected to gain access into the main page {cast ballot Screen} using his/her right thumb print for authentication.


a.k.a Page 1 / 2, Next 3 screen shots are the Cast Ballot Screen(s): - shown, in the first screen shot, is the voting page a.k.a cast ballot screen with sample presidential/vice presidential candidates. From the screen view, you would notice that this package is a two party e-voting system. Sample parties used are the two current strongholds in Nigeria i.e. PDP and APC.


The below screen displays the presidential/Vice Presidential screen with APC as the voters choice while the next screen displays the presidential/Vice Presidential screen with PDP as the voters choice.




The same process is used for Governor/Deputy Governor Screen which is Page 2 / 2,



Microsoft Sql server is used as the database design for this system.



Monday, December 16, 2013

Calculator ~~ VisualBasic Code Snippet + GUI Design


~Each button is named "btn follow by the control/tool text name". eg: button clear which is captioned 'c' is named btnc, button 0 is name btn0, button 1 is named btnone, button 2 is named btntwo............just like that. 
Note! -- except the resize event, every other line(s) of code is(are) click event.

~Still don't get it; Need the EXECUTABLE (.exe) file OR may be the design file itself; just holla at me;

----------------------------------------
Source Code ~> written with vbasic.net
----------------------------------------
Public Class Form1     ' class name

    Dim i As Double

    Dim sign As String
    Dim memory As Double

    Private Sub btnc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnc.Click

        txtdisplay.Text = 0
    End Sub

    Private Sub btn0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn0.Click

        mthd()
    End Sub

    Private Sub btntwo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btntwo.Click

        mthd()
    End Sub

    Private Sub btnone_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnone.Click

        mthd()
    End Sub

    Private Sub btnthree_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnthree.Click

        mthd()
    End Sub

    Private Sub btnfour_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnfour.Click

        mthd()
    End Sub

    Private Sub btnfive_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnfive.Click

        mthd()
    End Sub

    Private Sub btnsix_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsix.Click

        mthd()
    End Sub

    Private Sub btnseven_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnseven.Click

        mthd()
    End Sub

    Private Sub btneight_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btneight.Click

        mthd()
    End Sub

    Private Sub btnnine_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnnine.Click

        mthd()
    End Sub

    Public Sub mthd()

        If txtdisplay.Text = 0 Then
            txtdisplay.Text = Me.ActiveControl.Text
        Else
            txtdisplay.Text = txtdisplay.Text + Me.ActiveControl.Text
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        mthd()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        mthd()
    End Sub

    Private Sub btnplus_minus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnplus_minus.Click

        
        If txtdisplay.Text.StartsWith("-") Then
            txtdisplay.Text = txtdisplay.Text.Remove(0, 1)
        Else
            txtdisplay.Text = "-" + txtdisplay.Text
        End If
    End Sub

    Private Sub btnfraction_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnfraction.Click

        'calculating 1 divided by the value given
        txtdisplay.Text = (1 / txtdisplay.Text)
    End Sub

    Private Sub btnroot_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnroot.Click

        'calculating the square root
        txtdisplay.Text = Math.Sqrt(txtdisplay.Text)
    End Sub

    Private Sub btnspace_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnspace.Click

        ' Back_Space

        Dim lent As Integer

        lent = txtdisplay.TextLength

        If lent = 0 Then

        ElseIf lent = 1 Then
            txtdisplay.Text = 0
        Else
            txtdisplay.Text = txtdisplay.Text.Remove((lent) - 1)
        End If
    End Sub

    Private Sub btnplus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnplus.Click

        i = txtdisplay.Text
        sign = "+"
        txtdisplay.Text = 0
    End Sub

    Private Sub btnequals_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnequals.Click

        If sign = "+" Then
            txtdisplay.Text = (i + txtdisplay.Text)

        ElseIf sign = "-" Then

            txtdisplay.Text = (i - txtdisplay.Text)

        ElseIf sign = "*" Then

            txtdisplay.Text = (i * txtdisplay.Text)

        ElseIf sign = "/" Then

            txtdisplay.Text = (i / txtdisplay.Text)
        End If
    End Sub

    Private Sub btnminus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnminus.Click

        i = txtdisplay.Text
        sign = "-"
        txtdisplay.Text = 0
    End Sub

    Private Sub btntimes_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btntimes.Click

        i = txtdisplay.Text
        sign = "*"
        txtdisplay.Text = 0
    End Sub

    Private Sub btndivide_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndivide.Click

        i = txtdisplay.Text
        sign = "/"
        txtdisplay.Text = 0
    End Sub

    Private Sub btnmt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnmt.Click

        If txtdisplay.Text = 0 Then

        Else

            memory = txtdisplay.Text
        End If
    End Sub

    Private Sub btnmr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnmr.Click

        txtdisplay.Text = memory
    End Sub

    Private Sub btnpercent_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnpercent.Click

        txtdisplay.Text = (txtdisplay.Text / 100)
    End Sub

    

    Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
        ' resize event
        Me.Width = 264
        Me.Height = 332
    End Sub

End Class


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Scientific Calculator
~~~~~~~~~~~~~~~~
....Scientific calculator is a type of electronic calculator designed to calculate problems in science, engineering and mathematics. They have almost completely replaced slide rules in almost all traditional applications, and are widely used in both education and professional settings. Definition from ~http://en.wikipedia.org/wiki/Scientific_calculator

....Simple scientific calculator design and source code using Microsoft visual basic.net 2010. for now, i could only add the listed/shown functions. 
....need the EXECUTABLE (.exe) file? no worries;
Calculating 4 combination 2 (4C2) AND logarithm of 6 (log6) respectively




















-----------
Source Code
-----------
Public Class frmScientific

    Dim memory As Double
    Public i As Double
    Public sign As String

    'nPr variables declaration
    Public start1 As Double
    Public start11 As Double
    Public count1 As Double = 1
    Public count11 As Double = 1
    Public ii As Double

    'nCr variables declaration
    Public start1c As Double
    Public sstart1c As Double
    Public count1c As Double = 1
    Public scount1c As Double = 1
    Public start1cc As Double
    Public count1cc As Double = 1
    Public iic As Double

    Public Sub mthd()
        If txtdisplay1.Text = 0 Then
            txtdisplay1.Text = Me.ActiveControl.Text
        Else
            txtdisplay1.Text = txtdisplay1.Text + Me.ActiveControl.Text
        End If

    End Sub

    Private Sub btn_del_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_del.Click
        txtdisplay.Text = String.Empty
        ' BackSpace

        Dim txt_length As Integer
        txt_length = txtdisplay1.TextLength

        If txt_length = 0 Then
        ElseIf txt_length = 1 Then
            txtdisplay1.Text = 0
        Else
            txtdisplay1.Text = txtdisplay1.Text.Remove((txt_length) - 1)
        End If
    End Sub

    Private Sub btn_plusMinus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_plusMinus.Click

        ' Preceeding Addition/Subtraction
        If txtdisplay1.Text.StartsWith("-") Then
            txtdisplay1.Text = txtdisplay1.Text.Remove(0, 1)
        Else
            txtdisplay1.Text = "-" + txtdisplay1.Text
        End If
    End Sub

    Private Sub btn_zero_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_zero.Click
        mthd()
    End Sub

    Private Sub btn_one_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_one.Click
        mthd()
    End Sub

    Private Sub btn_two_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_two.Click
        mthd()
    End Sub

    Private Sub btn_three_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_three.Click
        mthd()
    End Sub

    Private Sub btn_four_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_four.Click
        mthd()
    End Sub

    Private Sub btn_five_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_five.Click
        mthd()
    End Sub

    Private Sub btn_six_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_six.Click
        mthd()
    End Sub

    Private Sub btn_seven_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_seven.Click
        mthd()
    End Sub

    Private Sub btn_eight_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_eight.Click
        mthd()
    End Sub

    Private Sub btn_nine_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_nine.Click
        mthd()
    End Sub

    Private Sub btn_c_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_c.Click

        txtcover.Visible = False
        txtdisplay.Text = String.Empty
        txtdisplay1.Text = 0

        init()
    End Sub

    Private Sub btn_dot_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_dot.Click
        mthd()
    End Sub

    Private Sub btn_multiply_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_multiply.Click
        txtdisplay.Text = String.Empty

        i = txtdisplay1.Text
        sign = "*"
        txtdisplay1.Text = 0
    End Sub

    Private Sub btn_divide_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_divide.Click
        txtdisplay.Text = String.Empty

        i = txtdisplay1.Text
        sign = "/"
        txtdisplay1.Text = 0
    End Sub

    Private Sub btn_plus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_plus.Click
        txtdisplay.Text = String.Empty

        i = txtdisplay1.Text
        sign = "+"
        txtdisplay1.Text = 0
    End Sub

    Private Sub btn_minus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_minus.Click
        txtdisplay.Text = String.Empty

        i = txtdisplay1.Text
        sign = "-"
        txtdisplay1.Text = 0
    End Sub

    Private Sub btn_equals_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_equals.Click
        txtdisplay.Text = String.Empty
        '  Dim all As String

        If sign = "+" Then
            txtdisplay.Text = i.ToString + " " + "+" + " " + txtdisplay1.Text.ToString
            txtdisplay1.Text = (i + txtdisplay1.Text)

        ElseIf sign = "-" Then
            txtdisplay.Text = i.ToString + " " + "-" + " " + txtdisplay1.Text.ToString
            txtdisplay1.Text = (i - txtdisplay1.Text)

        ElseIf sign = "*" Then
            txtdisplay.Text = i.ToString + " " + "*" + " " + txtdisplay1.Text.ToString
            txtdisplay1.Text = (i * txtdisplay1.Text)

        ElseIf sign = "/" Then
            txtdisplay.Text = i.ToString + " " + "/" + " " + txtdisplay1.Text.ToString
            txtdisplay1.Text = (i / txtdisplay1.Text)

        ElseIf sign = "p" Then

            Dim v As Double
            v = (ii - txtdisplay1.Text)

            For Me.start11 = 1 To v
                count11 = count11 * start11
            Next start11

            txtdisplay.Text = ii.ToString + "P" + txtdisplay1.Text.ToString
            txtdisplay1.Text = (count1 / count11)

            init()

        ElseIf sign = "c" Then
            '''''''''
            Dim vvv As Double
            vvv = (iic - txtdisplay1.Text)

            For Me.sstart1c = 1 To vvv
                scount1c = scount1c * sstart1c
            Next sstart1c
            ''''''''''
            Dim vv As Double
            vv = txtdisplay1.Text

            For Me.start1cc = 1 To vv
                count1cc = count1cc * start1cc
            Next start1cc
            '''''''''
            txtdisplay.Text = iic.ToString + "C" + txtdisplay1.Text.ToString
            txtdisplay1.Text = (count1c / (scount1c * count1cc))

            init()

        ElseIf sign = "^" Then

            txtdisplay.Text = i.ToString + "^" + txtdisplay1.Text.ToString
            txtdisplay1.Text = Math.Pow(i, txtdisplay1.Text)
        End If

    End Sub

    Private Sub btn_nCr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_nCr.Click

        iic = txtdisplay1.Text
        i = txtdisplay1.Text
        sign = "c"

        For Me.start1c = 1 To i
            count1c = count1c * start1c
        Next start1c

        txtdisplay1.Text = 0
       
    End Sub

    Private Sub btn_factorial_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_factorial.Click

        txtdisplay.Text = txtdisplay1.Text.ToString + "!"

        Dim start As Double
        Dim count As Double = 1

        For start = 1 To txtdisplay1.Text
            count = count * start
        Next start

        txtdisplay1.Text = count

    End Sub

    Private Sub btn_off_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_off.Click

        txtcover.Visible = True
        txtdisplay1.Text = 0
        txtdisplay.Text = String.Empty

    End Sub

    Private Sub btn_nPr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_nPr.Click

        ii = txtdisplay1.Text
        i = txtdisplay1.Text
        sign = "p"

        For Me.start1 = 1 To i
            count1 = count1 * start1
        Next start1

        txtdisplay1.Text = 0

    End Sub

    Private Sub btn_x3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_x3.Click

        txtdisplay.Text = txtdisplay1.Text.ToString + "^" + "3"
        txtdisplay1.Text = Math.Pow(txtdisplay1.Text, 3)

    End Sub

    Private Sub btn_log_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_log.Click

        txtdisplay.Text = "log" + " " + txtdisplay1.Text.ToString
        txtdisplay1.Text = Math.Log(txtdisplay1.Text)

    End Sub

    Private Sub btn_sin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_sin.Click

        txtdisplay.Text = "Sin" + " " + txtdisplay1.Text.ToString
        txtdisplay1.Text = Math.Sin(txtdisplay1.Text)
    End Sub

    Private Sub btn_cos_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_cos.Click

        txtdisplay.Text = "Cos" + " " + txtdisplay1.Text.ToString
        txtdisplay1.Text = Math.Cos(txtdisplay1.Text)

    End Sub

    Private Sub btn_tan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_tan.Click

        txtdisplay.Text = "Tan" + " " + txtdisplay1.Text.ToString
        txtdisplay1.Text = Math.Tan(txtdisplay1.Text)

    End Sub

    Private Sub btn_pi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_pi.Click

        txtdisplay1.Text = Math.PI

    End Sub

    Private Sub btn_squareroot_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_squareroot.Click

        txtdisplay.Text = "Sqrt" + " " + txtdisplay1.Text.ToString
        txtdisplay1.Text = Math.Sqrt(txtdisplay1.Text)
    End Sub

    Private Sub btn_percent_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_percent.Click

        txtdisplay.Text =  txtdisplay1.Text.ToString + "%"
        txtdisplay1.Text = (txtdisplay1.Text / 100)
    End Sub

    Private Sub btn_fraction_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_fraction.Click

        txtdisplay.Text = "1/" + txtdisplay1.Text.ToString
        txtdisplay1.Text = (1 / txtdisplay1.Text)

    End Sub

    Private Sub btn_x_y_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_x_y.Click

        i = txtdisplay1.Text
        sign = "^"
        txtdisplay1.Text = 0
    End Sub

    Private Sub btn_x2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_x2.Click

        txtdisplay.Text = txtdisplay1.Text.ToString + "^" + "2"
        txtdisplay1.Text = Math.Pow(txtdisplay1.Text, 2)

    End Sub

    Private Sub btn_exp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_exp.Click

        txtdisplay.Text = "Exp" + " " + txtdisplay1.Text.ToString
        txtdisplay1.Text = Math.Exp(txtdisplay1.Text)

    End Sub

    Private Sub btn_logInverse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_logInverse.Click

        txtdisplay.Text = "log^-1" + " " + txtdisplay1.Text.ToString
        txtdisplay1.Text = (1 / Math.Log(txtdisplay1.Text))

    End Sub

    Private Sub btn_sinInverse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_sinInverse.Click

        txtdisplay.Text = "Sin^-1" + " " + txtdisplay1.Text.ToString
        txtdisplay1.Text = (1 / Math.Sin(txtdisplay1.Text))

    End Sub

    Private Sub btn_cosInverse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_cosInverse.Click

        txtdisplay.Text = "Cos^-1" + " " + txtdisplay1.Text.ToString
        txtdisplay1.Text = (1 / Math.Cos(txtdisplay1.Text))

    End Sub

    Private Sub btn_tanInverse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_tanInverse.Click

        txtdisplay.Text = "Tan^-1" + " " + txtdisplay1.Text.ToString
        txtdisplay1.Text = (1 / Math.Tan(txtdisplay1.Text))

    End Sub

    Private Sub btn_mt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_mt.Click

        If txtdisplay1.Text = 0 Then

        Else
            memory = txtdisplay1.Text
        End If

    End Sub

    Private Sub btn_mr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_mr.Click

        txtdisplay.Text = "m"
        txtdisplay1.Text = memory
    End Sub


    Public Sub init()
        i = 0
        start1 = 0
        start11 = 0
        count1 = 1
        count11 = 1
        ii = 0
        start1c = 0
        sstart1c = 0
        count1c = 1
        scount1c = 1
        start1cc = 0
        count1cc = 1
        iic = 0
    End Sub

    Private Sub frmScientific_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
        Me.Width = 266
        Me.Height = 451
    End Sub
End Class