Calcualate in button click action

Saranya Boopathi
Posted by Saranya Boopathi under VB.NET category on | Points: 40 | Views : 801
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="test.aspx.vb" Inherits="Calculator" %>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
Your height (in inches):
<asp:TextBox ID="height" runat="server"></asp:TextBox><br />
<br />
Weight (in pounds):
<asp:TextBox ID="weight" runat="server"></asp:TextBox><br />
<br />
<asp:Button ID="btnSubmit" runat="server" Text="Calculate" /><br />
<br />
<asp:Label ID="results" runat="server"></asp:Label></div>
</form>
</body>
</html>


File: test.aspx.vb


Partial Class Calculator
Inherits System.Web.UI.Page

Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim h As Integer = height.Text
Dim w As Integer = weight.Text

Dim result As Double
result = w / h

results.Text = "value is " & result

End Sub
End Class

Comments or Responses

Login to post response