You are on page 1of 7

Public Class Form1

Dim previous As Double


Dim current As Double
Dim tempValue As Double
Dim hasDecimal As Boolean
Dim status As Boolean
Dim clearText As Boolean
Dim calcFunc As String

Sub calculation()
current = CDbl(TextBox1.Text)
If current = 0 Then
MessageBox.Show("Division by Zero is Undefined.")
End If
Select Case calcFunc
Case "add"
previous = previous + current
Case "sub"
previous = previous - current
Case "mult"
previous = previous * current
Case "div"
previous = previous / current
End Select
TextBox1.Text = previous
status = False

End Sub

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


If status Then
TextBox1.Text &= Button1.Text
Else
TextBox1.Text = Button1.Text
status = True
End If
End Sub

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


If status Then
TextBox1.Text &= Button2.Text
Else
TextBox1.Text = Button2.Text
status = True
End If
End Sub

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click


If status Then
TextBox1.Text &= Button3.Text
Else
TextBox1.Text = Button3.Text
status = True
End If
End Sub

Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click


If status Then
TextBox1.Text &= Button5.Text
Else
TextBox1.Text = Button5.Text
status = True
End If
End Sub

Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click


If status Then
TextBox1.Text &= Button6.Text
Else
TextBox1.Text = Button6.Text
status = True
End If
End Sub

Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click


If status Then
TextBox1.Text &= Button7.Text
Else
TextBox1.Text = Button7.Text
status = True
End If
End Sub

Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click


If status Then
TextBox1.Text &= Button9.Text
Else
TextBox1.Text = Button9.Text
status = True
End If
End Sub

Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click


If status Then
TextBox1.Text &= Button10.Text
Else
TextBox1.Text = Button10.Text
status = True
End If
End Sub

Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click


If status Then
TextBox1.Text &= Button11.Text
Else
TextBox1.Text = Button11.Text
status = True
End If
End Sub

Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Button13.Click


If status Then
If TextBox1.Text.Length >= 1 Then
TextBox1.Text = TextBox1.Text & Button13.Text
End If
End If
End Sub

Private Sub Button14_Click(sender As Object, e As EventArgs) Handles Button14.Click


If status Then
If Not hasDecimal Then
If TextBox1.Text.Length >= 1 Then
If Not TextBox1.Text = "0" Then
TextBox1.Text = TextBox1.Text & Button14.Text
hasDecimal = True
End If
Else
TextBox1.Text = "0."
End If
End If
'TextBox1.Text = "0."
End If

End Sub

Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click


If TextBox1.Text.Length <> 0 Then
If calcFunc = String.Empty Then
previous = CDbl(TextBox1.Text)
TextBox1.Text = String.Empty
Else
'call function here
Calculation()
End If
calcFunc = "mult"
hasDecimal = False
End If
End Sub

Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click


If TextBox1.Text.Length <> 0 Then
If calcFunc = String.Empty Then
previous = CDbl(TextBox1.Text)
TextBox1.Text = String.Empty
Else
'call function here
Calculation()
End If
calcFunc = "mult"
hasDecimal = False
End If

End Sub

Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click


If TextBox1.Text.Length <> 0 Then
If calcFunc = String.Empty Then
previous = CDbl(TextBox1.Text)
TextBox1.Text = String.Empty
Else
'call function here
Calculation()
End If
calcFunc = "mult"
hasDecimal = False
End If

End Sub

Private Sub Button16_Click(sender As Object, e As EventArgs) Handles Button16.Click


If TextBox1.Text.Length <> 0 Then
If calcFunc = String.Empty Then
previous = CDbl(TextBox1.Text)
TextBox1.Text = String.Empty
Else
'call function here
Calculation()
End If
calcFunc = "mult"
hasDecimal = False
End If

End Sub

Private Sub Button15_Click(sender As Object, e As EventArgs) Handles Button15.Click


calculation()
End Sub

Private Sub Button17_Click(sender As Object, e As EventArgs) Handles Button17.Click


TextBox1.Text = String.Empty
previous = 0

End Sub

Private Sub Button18_Click(sender As Object, e As EventArgs) Handles Button18.Click


End
End Sub

' Statistics Calculator Part


Dim amu As Integer
Dim mean As Double
Dim median As Double
Dim mode As Double
Dim varT As Double ' variance total
Dim stanDiv As Double ' Standard deviation
Dim sscore As Double ' Standardize score
Dim vari As Double ' variance
Dim total As Double

Sub calcStat()
'Accepts the Amount of the Number you like to Calculate
amu = InputBox("How many Numbers do you want to Calculate", "STATISTICS
CALCULATOR")

Dim num(amu) As Double

'Calculating Mean and Accept Values you want to Calculate


Dim i As Integer
For i = 0 To amu - 1
num(i) = InputBox("Enter " & amu & " Numbers", "STATISTICS CALCULATOR")
total += num(i)
Next
mean = total / amu

'Calculating Median
If amu Mod 2 = 0 Then 'If amu remainder is zero it is even else it is odd
Array.Sort(num)
median = (num(amu / 2 - 0.5) + num(amu / 2 + 0.5)) / 2
Else
Array.Sort(num)
median = num(amu / 2 + 0.5)
End If

'calculating variance
For i = 0 To amu - 1
varT += Math.Pow(2, num(i))
Next
vari = varT / amu

'calculating Standard devation


stanDiv = Math.Sqrt(vari)

'Calculating Standardize Score


sscore = (amu - mean) / stanDiv
End Sub

Private Sub Button20_Click(sender As Object, e As EventArgs) Handles Button20.Click


calcStat()
End Sub

Private Sub Button19_Click(sender As Object, e As EventArgs) Handles Button19.Click


TextBox1.Text = mean
End Sub

Private Sub Button21_Click(sender As Object, e As EventArgs) Handles Button21.Click


TextBox1.Text = median
End Sub

Private Sub Button22_Click(sender As Object, e As EventArgs) Handles Button22.Click


TextBox1.Text = mode
End Sub

Private Sub Button23_Click(sender As Object, e As EventArgs) Handles Button23.Click


TextBox1.Text = stanDiv
End Sub

Private Sub Button24_Click(sender As Object, e As EventArgs) Handles Button24.Click


TextBox1.Text = vari
End Sub

Private Sub Button25_Click(sender As Object, e As EventArgs) Handles Button25.Click


TextBox1.Text = sscore
End Sub

Private Sub StaToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles


StaToolStripMenuItem.Click
Me.Text = "Statistics Calculator"
TextBox1.Width = 313
Me.Width = 350
Me.Height = 389
End Sub

Private Sub StandardToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles


StandardToolStripMenuItem.Click
Me.Text = "Standard Calculator"
TextBox1.Width = 238
Me.Width = 270
Me.Height = 381
End Sub

Private Sub AboutToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles


AboutToolStripMenuItem.Click
About_Calculator.Show()
End Sub

Private Sub ViewHelpToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles


ViewHelpToolStripMenuItem.Click
Help.Show()
End Sub
End Class
Imports System.Data.OleDb

Public Class Form1


Dim provider As String
Dim df As String
Dim connstr As String
Dim conn As OleDbConnection = New OleDbConnection
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

End Sub

Private Sub Label4_Click(sender As Object, e As EventArgs)

End Sub

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


provider = "providerMicrosoft.ACE.OLEDB.12.0;Data source= sis.accdb"
connstr = provider
conn.ConnectionString = connstr
conn.Open()
Dim cmd As OleDbCommand = New OleDbCommand(SELE * From[user] WHERE
[USERNAME]='"&textbox1.TEXT&"'AND[password]="&textbox2.TEXT&"",conn)

End Sub
End Class

You might also like