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 

Monday, November 18, 2013

Multiplication Table (times table); "Java Code"

 multiplication table a.k.a "times table" using Java as requested by you "my friend".
In mathematics, a multiplication table (sometimes, less formally, times table) is a mathematical table used to define a multiplication operation for an algebraic system. http://en.wikipedia.org/wiki/Multiplication_table 

---------
Source  Code
---------
// static import
import static java.lang.System.out;

// class name
class MultiplicationTable
{
// variable declaration
 int i, j;

//constructor
MultiplicationTable()
{
// for loop
   for (i = 1; i <=12; i++)
   {
      for (j = 1; j <=12; j++)
      {

      out.printf("%d\t", i*j);

      if (j == 12)
       out.println();
      }
   }
}
      // main method
public static void main(String [] args)
{
     // constructor call
new MultiplicationTable();
}
 }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Simply copy the above code and paste in any IDE (integrated development environment) of your choice, then compile and run. You can set d upper bound limit which is 12 in this code, "see line 14 and 16", to any limit of your choice by editing the limit set in the code (from the for loop). 
Below is what your output should look like after running;










Monday, November 11, 2013

An Application Package on Linear Regression Analysis ~~ VisualBasic Code Snippet + GUI Design

Okkk.. as promised, here is my app package(software) on Simple Linear Regression Analysis Using Visual basic.
Fact! i said in the beginning that every post i make will be for those who know OR have little knowledge about programming. if you don't, then, you need help ~~> 4rm some1 who knows some1 who knows some1 who knows how to program.....lol......just joking....... u need to learn it some how.
"Some1 asked me ~ is it a robust program?" i answered ~~ that 's an meant for you to figure out. you too, yes! you;
          -----------------
          Screen shots
          -----------------


               --------------
                Source Code
               --------------
Public Class frmmain
    Public n As Integer

    Public xCount As Double
    Public countx As Integer, counterx As Integer

    Public yCount As Double
    Public county As Integer, countery As Integer

    Public x_yCount As Double
    Public countxt As Integer, counterxt As Integer

    Public x_xCount As Double
    Public countxSquare As Integer, counterxSquare As Integer

    Public xxCount As Double
    Public countxx As Integer, counterxx As Integer

    Public xyCount As Double
    Public countxy As Integer, counterxy As Integer

    Public y_yCount As Double
    Public countySquare As Integer, counterySquare As Integer

    Public yyCount As Double
    Public countyy As Integer, counteryy As Integer

    Public ymean As Double, xmean As Double

    Public slope As Double, intercept As Double, lstSquare As Double,         pearsons As Double, standarderror As Double

    Public i As Integer ' for scatter plot

    Private Sub CmdAddx_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdAddx.Click
        Try
            If txtXvalue.Text = Double.NaN Then
            End If
        Catch ex As Exception
            MessageBox.Show("Value entered is not a number, Enter value of type integer or double", "SLRegression", MessageBoxButtons.OK, MessageBoxIcon.Information)
            txtXvalue.Focus()
            GoTo uuu
        End Try

        If txtXvalue.Text = String.Empty Then
        Else
            lstx.Items.Add(txtXvalue.Text)
            txtXvalue.Text = String.Empty

            txtXvalue.Focus()
        End If
uuu:
End Sub

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

    Private Sub ClearTheValuesOfXToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearTheValuesOfXToolStripMenuItem.Click
        lstx.Items.Clear()
    End Sub

    Private Sub ClearTheValuesOfYToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearTheValuesOfYToolStripMenuItem.Click
        lsty.Items.Clear()
    End Sub

    Private Sub cmdAddy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAddy.Click
        Try
            If txtYvalue.Text = Double.NaN Then
            End If
        Catch ex As Exception
            MessageBox.Show("Value entered is not a number, Enter value of type integer or double", "SLRegression", MessageBoxButtons.OK, MessageBoxIcon.Information)
            txtYvalue.Focus()
            GoTo yyy
        End Try

        If txtYvalue.Text = String.Empty Then
        Else

            lsty.Items.Add(txtYvalue.Text)
            txtYvalue.Text = String.Empty
            txtYvalue.Focus()
        End If
yyy:
    End Sub

    Public Sub AllResultsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AllResultsToolStripMenuItem.Click
        If lstx.Items.Count = 0 Or lsty.Items.Count = 0 Then
            MessageBox.Show("No input values for x or y", "SLRegression", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            txtXvalue.Focus()
            GoTo empty
        End If

        If lstx.Items.Count = 1 Or lsty.Items.Count = 1 Then
            MessageBox.Show("Required input should be more than 1 for both x & y", "SLRegression", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            txtXvalue.Focus()
            GoTo empty
        End If

        If lstx.Items.Count = lsty.Items.Count Then

            xCount = 0
            yCount = 0
            x_xCount = 0
            y_yCount = 0
            x_yCount = 0
            xxCount = 0
            xyCount = 0
            yyCount = 0
            ymean = 0
            xmean = 0
            slope = 0
            intercept = 0
            lstSquare = 0
            pearsons = 0
            i = 0
            lstxx.Items.Clear()
            lstxy.Items.Clear()
            lstyy.Items.Clear()

            'Public Sub n() ' entry count
            n = lstx.Items.Count
            ' End Sub

            ' Public Sub sumOfx()     ' SUM OF X
            countx = lstx.Items.Count

            For counterx = 1 To countx
                xCount = xCount + lstx.Items(counterx - 1)
            Next
            'End Sub

            ' Public Sub sumOfy()        ' SUM OF Y
            county = lsty.Items.Count

            For countery = 1 To county
                yCount = yCount + lsty.Items(countery - 1)
            Next
            '  End Sub

            ' Public Sub computexXy() ' COMPUTING X TIMES Y // xt, where t for times

            ' initialising variables
            lstxy.Items.Clear()
            countxt = lstx.Items.Count
            For counterxt = 1 To countxt

           x_yCount = ((lstx.Items(counterxt - 1)) * (lsty.Items(counterxt - 1)))

           lstxy.Items.Add(x_yCount)
            Next
            ' End Sub

            ' Public Sub computexXx()    ' COMPUTING X TIMES X
            ' initialising variables
            countxSquare = lstx.Items.Count

            For counterxSquare = 1 To countxSquare
                x_xCount = ((lstx.Items(counterxSquare - 1)) * (lstx.Items(counterxSquare - 1)))

                lstxx.Items.Add(x_xCount)
            Next
            ' End Sub

            '   Public Sub sumOfxx()  'SUM OF X TIMES X
            countxx = lstxx.Items.Count

            For counterxx = 1 To countxx
                xxCount = xxCount + lstxx.Items(counterxx - 1)
            Next
            '   End Sub

            '     Public Sub sumOfxy() ' SUM OF X*Y

            countxy = lstxy.Items.Count
            For counterxy = 1 To countxy
                xyCount = xyCount + lstxy.Items(counterxy - 1)
            Next
            '      End Sub

            ' Public Sub computeyXy()    ' COMPUTING Y TIMES Y

            ' initialising variables
            countySquare = lsty.Items.Count

            For counterySquare = 1 To countySquare
                y_yCount = ((lsty.Items(counterySquare - 1)) * (lsty.Items(counterySquare - 1)))

                lstyy.Items.Add(y_yCount)
            Next
            ' End Sub

            '   Public Sub sumOfyy()  'SUM OF Y TIMES Y

            countyy = lstyy.Items.Count

            For counteryy = 1 To countyy
                yyCount = yyCount + lstyy.Items(counteryy - 1)
            Next
            '   End Sub

            ' FILLING VACANT SPACES
            lblSumOfX.Text = xCount
            lblSumOfY.Text = yCount
            lblSumOfXY.Text = xyCount
            lblSumOfXX.Text = xxCount
            lblSumOfYY.Text = yyCount

            ' GETTING THE MEAN OF X & Y
            ymean = yCount / n
            xmean = xCount / n

            ' Calculating the slope  -- b
            slope = ((n * xyCount) - (xCount * yCount)) / ((n * xxCount) - (xCount * xCount))

            ' Calculating the intercept -- a
            intercept = (yCount / n) - (slope * (xCount / n))

            ' COMPUTIN D LST SQUARE
            lstSquare = Math.Sqrt(((intercept * yyCount) - (slope * xyCount) - (n * (ymean * ymean))) / (yyCount - (n * (ymean * ymean))))

            ' COMPUTING THE STANDARD_ERROR OF ESTIMATION
            standarderror = (Math.Sqrt((yCount * yCount) - (intercept * yCount) - (slope * xyCount)) / Math.Sqrt(n - 2))

            ' COMPUTING PEARSONS CofC
            pearsons = (xyCount - (n * xmean * ymean)) / Math.Sqrt((yyCount - (n * (ymean * ymean))) * (xxCount - (n * (xmean * xmean))))

            lblResult.Text = "  The mean of x is " & Math.Round(xmean, 2) & " ; " & "The mean of y is " & Math.Round(ymean, 2) _
                    & " ; " & "The Regression line y = " & Math.Round(intercept, 2) & " + " & Math.Round(slope, 2) & "x" & _
                    "  " & vbCr & "  The Standard error of estimation = " & Math.Round(standarderror, 2) & _
                    "  " & vbCr & "  The Pearsons Coefficient of Correlation (r) = " & Math.Round(pearsons, 2)

            '' PLOtting the graph
            'TextBox1.Text = lstSquare
            ScatterPlot.chartType = MSChart20Lib.VtChChartType.VtChChartType2dXY

            ScatterPlot.RowCount = n
            ScatterPlot.ColumnCount = 2

            For i = 1 To ScatterPlot.RowCount

                ScatterPlot.Row = i
                ScatterPlot.RowLabel = i

                ScatterPlot.Column = 1
                ScatterPlot.Data = lstx.Items(i - 1)

                ScatterPlot.Column = 2
                ScatterPlot.Data = lsty.Items(i - 1)
            Next
            Scattercover.Visible = Fals
        Else
            MessageBox.Show("No corresponding y value for a given value of x or vice-versa", "SLRegression", MessageBoxButtons.OK, MessageBoxIcon.Information)
        End If
empty:
        If lstx.Items.Count = 0 Then
            lblResult.Text = String.Empty
        Else
        End If

        '' the regression line
        ScatterPlot.Plot.SeriesCollection(1).StatLine.Flag = MSChart20Lib.VtChStats.VtChStatsRegression
    End Sub

    Private Sub ScatterPlotToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ScatterPlotToolStripMenuItem.Click
        Me.AllResultsToolStripMenuItem.PerformClick()
        lblResult.Text = String.Empty

        If lstx.Items.Count = 0 Then
            lblResult.Text = String.Empty
        End If
    End Sub

    Private Sub XMeanToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles XMeanToolStripMenuItem.Click
        Me.AllResultsToolStripMenuItem.PerformClick()

        Scattercover.Visible = True
        If lstx.Items.Count = 0 Then
            lblResult.Text = String.Empty
        Else
            lblResult.Text = "The mean of x is " & Math.Round(xmean, 2)
        End If
    End Sub

    Private Sub YMeanToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles YMeanToolStripMenuItem.Click
        Me.AllResultsToolStripMenuItem.PerformClick()
        Scattercover.Visible = True

        If lstx.Items.Count = 0 Then
            lblResult.Text = String.Empty
        Else
            lblResult.Text = "The mean of y is " & Math.Round(ymean, 2)
        End If
    End Sub

    Private Sub TheRegressionLineToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TheRegressionLineToolStripMenuItem.Click
        Me.AllResultsToolStripMenuItem.PerformClick()
        Scattercover.Visible = True

        If lstx.Items.Count = 0 Then
            lblResult.Text = String.Empty
        Else
            lblResult.Text = "The Regression line y = " & Math.Round(intercept, 2) & " + " & Math.Round(slope, 2) & "x"
        End If
    End Sub

    Private Sub LeastSquareToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LeastSquareToolStripMenuItem.Click
        Me.AllResultsToolStripMenuItem.PerformClick()
        Scattercover.Visible = True

        If lstx.Items.Count = 0 Then
            lblResult.Text = String.Empty
        Else
            lblResult.Text = "The LeastSquare of the Regression line = " & Math.Round(lstSquare, 2)
        End If
    End Sub

    Private Sub PearsonsCOfCToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PearsonsCOfCToolStripMenuItem.Click
        Me.AllResultsToolStripMenuItem.PerformClick()
        Scattercover.Visible = True

        If lstx.Items.Count = 0 Then
            lblResult.Text = String.Empty
        Else
            lblResult.Text = "The Pearsons Coefficient of Correlation for the Regression line r = " & Math.Round(pearsons, 2)
        End If
    End Sub

    Private Sub BlankResultPageToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click
        If Scattercover.Visible = False Then
            Scattercover.Visible = True
        End If
        ResultsToolStripMenuItem.Enabled = True
        ClearTheValuesOfXToolStripMenuItem.Enabled = True
        ClearTheValuesOfYToolStripMenuItem.Enabled = True
        lblcover.Visible = False
        lstx.Items.Clear()
        lsty.Items.Clear()
        lstxy.Items.Clear()
        lstxx.Items.Clear()
        lstyy.Items.Clear()
        lblSumOfX.Text = ""
        lblSumOfY.Text = ""
        lblSumOfXX.Text = ""
        lblSumOfXY.Text = ""
        lblSumOfYY.Text = ""
        lblResult.Text = String.Empty

    End Sub

    Private Sub cmdRemoveX_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRemoveX.Click
        lstx.Items.Remove(lstx.SelectedItem)
    End Sub

    Private Sub cmdRemoveY_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRemoveY.Click
        lsty.Items.Remove(lsty.SelectedItem)
    End Sub

  
    Private Sub StandardErrorOfEstimationToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StandardErrorOfEstimationToolStripMenuItem.Click
        Me.AllResultsToolStripMenuItem.PerformClick()
        Scattercover.Visible = True

        If lstx.Items.Count = 0 Then
            lblResult.Text = String.Empty
        Else

            lblResult.Text = "The Standard Error of Estimation = " & Math.Round(standarderror, 2)
        End If
    End Sub
End Class


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Brief Description
Looking at the last screen shot, i included the name(s) of some control(s)/tool  for easy understanding of the program. Some of these contol(s) include
  • txtXValue: - text box for entering values of x
  • cmdAddX: - click on this button to add ‘x’ value(s) into list box x and vice-versa
  • cmdRemoveX: - use this button to remove values entered beginning from the last value
  • lblResult: - displays all results which include “the mean of both x and y”, “the regression line”, “the standard error of estimation” and “pearsons coefficient of correlation”
  • lstX: - shows all values of x entered
  • lstY: - shows all values of Y entered
  • lstXX: - shows the multiplication of each x value
  • lstXY: - shows the multiplication of each x and y value
  • lstYY: - shows the multiplication of each y value
  • ScatterPlot: - a plot of the observed bivariate outcome variable (y axis) against it predictor variable (x axis), with a dot for each pair of bivariate observations.
View the menu item(s) used in the design of this application











       Sample video on this application 

~~need the executable file (software) feel free to reach me