<%@ Page Language=VB Debug=true %>
<script runat=server>
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
If IsPostBack Then
DisplayInstructions("Final")
Else
DisplayInstructions("Initial")
End If
End Sub
Sub SubmitBtn_Click(Sender As Object, E As EventArgs)
lblResult.Text = "Result: " & AddNums( _
txtNumber1.Text, txtNumber2.Text)
End Sub
Sub DisplayInstructions(Mode as String)
If Mode = "Initial" Then
lblInstructions.Text = "Enter two numbers that " _
& "you want to add."
Else
lblInstructions.Text = "The results are " _
& "below."
End If
End Sub
Function AddNums(Num1 as Single, Num2 as Single) as Single
AddNums = Num1 + Num2
End Function
</script>
<HTML>
<HEAD>
<TITLE>Creating Your Own Procedures</TITLE>
</HEAD>
<Body LEFTMARGIN="40">
<form runat="server">
<asp:label
id="lblInstructions"
runat="server"
/>
<BR><BR>
Enter a number:<BR>
<asp:textbox
id="txtNumber1"
runat=server
/>
<BR><BR>
Enter a second number:<BR>
<asp:textbox
id="txtNumber2"
runat=server
/>
<BR><BR>
<asp:button
id="butOK"
text="Add"
onclick="SubmitBtn_Click"
runat="server"
/>
<BR><BR>
<asp:label
id="lblResult"
runat="server"
/>
</Form>
</BODY>
</HTML>
|