Det kan da godt være at jeg ikke lige har fået pakket det hele ned, så du får lige koden af mig istedet for:
<-- calculator.aspx -->
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="Calculator.aspx.vb" Inherits="myFirstProject.Calculator"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Calculator</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="
http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:Button id="Button1" style="Z-INDEX: 100; LEFT: 24px; POSITION: absolute; TOP: 72px" runat="server"
Text="1" Width="24px"></asp:Button>
<asp:Button id="ButtonDiv" style="Z-INDEX: 116; LEFT: 184px; POSITION: absolute; TOP: 192px"
runat="server" Width="24px" Text="/"></asp:Button>
<asp:Button id="ButtonGange" style="Z-INDEX: 115; LEFT: 184px; POSITION: absolute; TOP: 152px"
runat="server" Width="24px" Text="*"></asp:Button>
<asp:Button id="ButtonRes" style="Z-INDEX: 114; LEFT: 64px; POSITION: absolute; TOP: 192px"
runat="server" Width="24px" Text="="></asp:Button>
<asp:Button id="ButtonDel" style="Z-INDEX: 113; LEFT: 104px; POSITION: absolute; TOP: 192px"
runat="server" Width="24px" Text="CE"></asp:Button>
<asp:Button id="ButtonMinus" style="Z-INDEX: 112; LEFT: 184px; POSITION: absolute; TOP: 112px"
runat="server" Width="24px" Text="-"></asp:Button>
<asp:Button id="ButtonPlus" style="Z-INDEX: 111; LEFT: 184px; POSITION: absolute; TOP: 72px"
runat="server" Width="24px" Text="+"></asp:Button>
<asp:Button id="Button0" style="Z-INDEX: 110; LEFT: 24px; POSITION: absolute; TOP: 192px" runat="server"
Width="24px" Text="0"></asp:Button>
<asp:Button id="Button9" style="Z-INDEX: 109; LEFT: 104px; POSITION: absolute; TOP: 152px" runat="server"
Width="24px" Text="9"></asp:Button>
<asp:Button id="Button8" style="Z-INDEX: 108; LEFT: 64px; POSITION: absolute; TOP: 152px" runat="server"
Width="24px" Text="8"></asp:Button>
<asp:Button id="Button7" style="Z-INDEX: 107; LEFT: 24px; POSITION: absolute; TOP: 152px" runat="server"
Width="24px" Text="7"></asp:Button>
<asp:Button id="Button6" style="Z-INDEX: 106; LEFT: 104px; POSITION: absolute; TOP: 112px" runat="server"
Width="24px" Text="6"></asp:Button>
<asp:Button id="Button5" style="Z-INDEX: 105; LEFT: 64px; POSITION: absolute; TOP: 112px" runat="server"
Width="24px" Text="5"></asp:Button>
<asp:Button id="Button4" style="Z-INDEX: 104; LEFT: 24px; POSITION: absolute; TOP: 112px" runat="server"
Width="24px" Text="4"></asp:Button>
<asp:Button id="Button3" style="Z-INDEX: 103; LEFT: 104px; POSITION: absolute; TOP: 72px" runat="server"
Width="24px" Text="3"></asp:Button>
<asp:Button id="Button2" style="Z-INDEX: 101; LEFT: 64px; POSITION: absolute; TOP: 72px" runat="server"
Text="2" Width="24px"></asp:Button>
<asp:TextBox id="display" style="Z-INDEX: 102; LEFT: 24px; POSITION: absolute; TOP: 24px" runat="server"
Width="104px"></asp:TextBox></form>
</body>
</HTML>
<-- calculator.aspx.vb -->
Public Class Calculator
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents Button2 As System.Web.UI.WebControls.Button
Protected WithEvents display As System.Web.UI.WebControls.TextBox
Protected WithEvents Button3 As System.Web.UI.WebControls.Button
Protected WithEvents Button4 As System.Web.UI.WebControls.Button
Protected WithEvents Button5 As System.Web.UI.WebControls.Button
Protected WithEvents Button6 As System.Web.UI.WebControls.Button
Protected WithEvents Button7 As System.Web.UI.WebControls.Button
Protected WithEvents Button8 As System.Web.UI.WebControls.Button
Protected WithEvents Button9 As System.Web.UI.WebControls.Button
Protected WithEvents ButtonPlus As System.Web.UI.WebControls.Button
Protected WithEvents ButtonMinus As System.Web.UI.WebControls.Button
Protected WithEvents ButtonDel As System.Web.UI.WebControls.Button
Protected WithEvents ButtonRes As System.Web.UI.WebControls.Button
Protected WithEvents ButtonDiv As System.Web.UI.WebControls.Button
Protected WithEvents ButtonGange As System.Web.UI.WebControls.Button
Protected WithEvents Button0 As System.Web.UI.WebControls.Button
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
input(1)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
input(2)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
input(3)
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
input(4)
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
input(5)
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
input(6)
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
input(7)
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
input(8)
End Sub
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
input(9)
End Sub
Private Sub Button0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button0.Click
input(0)
End Sub
Private Sub ButtonPlus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonPlus.Click
OperatorClick("plus")
End Sub
Private Sub ButtonMinus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonMinus.Click
OperatorClick("minus")
End Sub
Private Sub ButtonGange_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonGange.Click
OperatorClick("gange")
End Sub
Private Sub ButtonDiv_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonDiv.Click
OperatorClick("div")
End Sub
Private Sub ButtonDel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonDel.Click
display.Text = ""
End Sub
Private Sub ButtonRes_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonRes.Click
Dim tal2 = CInt(display.Text)
Dim tal1 = CInt(Session("operand"))
If Session("operator") = "plus" Then
display.Text = tal1 + tal2
ElseIf Session("operator") = "minus" Then
display.Text = tal1 - tal2
ElseIf Session("operator") = "gange" Then
display.Text = tal1 * tal2
ElseIf Session("operator") = "div" Then
display.Text = tal1 / tal2
End If
Session("operand") = display.Text
End Sub
Private Sub OperatorClick(ByVal operator As String)
Session.Add("operand", display.Text)
Session.Add("operator", operator)
display.Text = ""
End Sub
Private Sub input(ByVal vaerdi As String)
display.Text &= vaerdi
End Sub
End Class