M =
any input number from user.
E= output of Energy. Rest figure out yourself.
Public Class mycalc
'for
close button declaration
Private Const MF_BYPOSITION
= &H400
Private Const MF_REMOVE
= &H1000
Private Const MF_DISABLED
= &H2
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As IntPtr,
ByVal nPosition AsInteger, ByVal wFlags As Long) As IntPtr
Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As IntPtr,
ByVal bRevert AsBoolean) As IntPtr
Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As IntPtr)
As Integer
Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As IntPtr) As Boolean
Public Sub DisableCloseButton(ByVal hwnd As IntPtr)
Dim hMenu As IntPtr
Dim menuItemCount As Integer
hMenu = GetSystemMenu(hwnd, False)
menuItemCount = GetMenuItemCount(hMenu)
Call RemoveMenu(hMenu,
menuItemCount - 1, MF_DISABLED Or MF_BYPOSITION)
Call RemoveMenu(hMenu,
menuItemCount - 2, MF_DISABLED Or MF_BYPOSITION)
Call DrawMenuBar(hwnd)
End Sub
Private Sub mycalc_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs)Handles MyBase.Load
Call DisableCloseButton(Me.Handle)
cmdcalculate.Text = "Calculate
(%) Add"
Label1.Hide()
Label2.Hide()
LblEdisplay.Hide()
End Sub
Private Sub Button1_Click_1(ByVal sender As System.Object,
ByVal e As System.EventArgs)Handles Button1.Click
lbdisplay.Text = Val(TextBox1.Text) + Val(TextBox2.Text)
End Sub
Private Sub Button7_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs)Handles Button7.Click
'e
= lbldisplay, c= textbox2.text
Label1.Show()
Label2.Show()
LblEdisplay.Show()
lbdisplay.Text = Val(TextBox1.Text) * (Val(TextBox2.Text) ^ 2)
End Sub
Private Sub Button2_Click_1(ByVal sender As System.Object,
ByVal e As System.EventArgs)Handles Button2.Click
lbdisplay.Text = Val(TextBox1.Text) - Val(TextBox2.Text)
End Sub
Private Sub Button6_Click_1(ByVal sender As System.Object,
ByVal e As System.EventArgs)Handles Button6.Click
lbdisplay.Text = ""
TextBox1.Text = ""
TextBox2.Text = ""
TextBox1.Show()
Label1.Hide()
Label2.Hide()
End Sub
Private Sub Button3_Click_1(ByVal sender As System.Object,
ByVal e As System.EventArgs)Handles Button3.Click
lbdisplay.Text = Val(TextBox1.Text) * Val(TextBox2.Text)
End Sub
Private Sub Button4_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs)Handles Button4.Click
lbdisplay.Text = Val(TextBox1.Text) / Val(TextBox2.Text)
End Sub
Private Sub Button5_Click_1(ByVal sender As System.Object,
ByVal e As System.EventArgs)Handles Button5.Click
lbdisplay.Text = Val(TextBox2.Text) / 100
End Sub
Private Sub cmdcalculate_Click_1(ByVal sender As System.Object,
ByVal e AsSystem.EventArgs) Handles cmdcalculate.Click
lbdisplay.Text = Val(TextBox2.Text) / 100
If cmdcalculate.Text
= "Calculate
(%) Add" Then
cmdcalculate.Text = "Calculate
(%) Subtract"
lbdisplay.Text = Val(TextBox1.Text) + lbdisplay.Text
Else
lbdisplay.Text = Val(TextBox1.Text) - lbdisplay.Text
cmdcalculate.Text = "Calculate
(%) Add"
Exit
Sub
End If
End Sub
Private Sub Button8_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs)Handles Button8.Click
'
m = 3.14, c= r, lbldisplay = A
Label1.Show()
Label2.Show()
TextBox1.Hide()
lbdisplay.Text = 3.14 * (Val(TextBox2.Text)) ^ 2
End Sub
Private Sub Button9_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs)Handles Button9.Click
'
m = 3.14, c= r, lbldisplay = A
Label1.Show()
Label2.Show()
TextBox1.Hide()
lbdisplay.Text = (2 * 3.14) * Val(TextBox2.Text)
End Sub
Private Sub Button10_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs)Handles Button10.Click
'L=textbox1.text,
W=textbox2.text, lbdisplay =A
'L
= m, W = c
Label1.Show()
Label2.Show()
lbdisplay.Text = Val(TextBox1.Text) * Val(TextBox2.Text)
End Sub
Private Sub Button11_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs)Handles Button11.Click
'L=textbox1.text,
W=textbox2.text, lbdisplay =Arean of triangle
'L
= m, W = c
Label1.Show()
Label2.Show()
lbdisplay.Text = 1 / 2 * Val(TextBox1.Text) * Val(TextBox2.Text)
End Sub
Private Sub Button12_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs)Handles Button12.Click
'lbdisplay
= Area of square, c = textbox2.text
Label1.Hide()
Label2.Show()
TextBox1.Hide()
lbdisplay.Text = (Val(TextBox2.Text)) ^ 2
End Sub
Private Sub Button13_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs)Handles Button13.Click
'b=textbox1.text,
h=textbox2.text, lbdisplay =A
'b
= m, h = c
Label1.Show()
Label2.Show()
lbdisplay.Text = Val(TextBox1.Text) * Val(TextBox2.Text)
End Sub
Private Sub Button14_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs)Handles Button14.Click
'a=textbox1.text,
h=textbox2.text, lbdisplay =A
'a
= m, h = c
Dim b As Integer
Label1.Show()
Label2.Show()
b = InputBox("Enter
value of b")
lbdisplay.Text = 1 / 2 * (Val(TextBox1.Text) + b) * Val(TextBox2.Text)
End Sub
Private Sub Button15_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs)Handles Button15.Click
'lbdisplay
= Area of square, r(c) = textbox2.text, Th = Theta
Dim Th As Integer
Th = InputBox("Enter
value of theta")
Label1.Hide()
Label2.Show()
TextBox1.Hide()
lbdisplay.Text = 1 / 2 * (Val(TextBox2.Text)) ^ 2 * Th
End Sub
Private Sub Button16_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs)Handles Button16.Click
'a=textbox1.text,
b=textbox2.text, lbdisplay =Arean of Ellipse
'a
= m, b = c
Label1.Show()
Label2.Show()
lbdisplay.Text = 3.14 * Val(TextBox1.Text) * Val(TextBox2.Text)
End Sub
Private Sub Button17_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs)Handles Button17.Click
Dim msg As String
Dim title As String
Dim style As String
Dim response As String
msg = "Do
you want to continue?"
style = MsgBoxStyle.DefaultButton2 Or MsgBoxStyle.Question Or MsgBoxStyle.YesNo
title = "Quitting
Calculator APP"
response = MsgBox(msg, style, title)
If response
= MsgBoxResult.No Then
MsgBox("You
cannot quit, clear values please!")
Exit
Sub
Me.Close()
Else
End
End If
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object,
ByVal e AsSystem.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub GroupBox1_Enter(ByVal sender As System.Object,
ByVal e As System.EventArgs)Handles GroupBox1.Enter
End Sub
End Class