NEED HELP WITH CALCULATOR WEB SERVICE

C

conspawn

Whats up guys, i am having difficulties coding the plus sign button on
my aspx page to store variable1, clear textbox, and store variable2
then call a web service to add both variables

my code so far is:
<%@ Page Language="VB" %>
<%@ import Namespace="WebSCalculator" %>
<script runat="server">

Private Sub btnZero_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles btnzero.Click

txtDisplay.Text = txtDisplay.Text & btnzero.Text


End Sub

Private Sub btnone_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles btnone.Click

txtDisplay.Text = txtDisplay.Text & btnone.Text

End Sub

Private Sub btntwo_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles btntwo.Click

txtDisplay.Text = txtDisplay.Text & btntwo.Text

End Sub

Private Sub btnthree_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles btnthree.Click

txtDisplay.Text = txtDisplay.Text & btnthree.Text

End Sub

Private Sub btnfour_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles btnfour.Click

txtDisplay.Text = txtDisplay.Text & btnfour.Text

End Sub

Private Sub btnfive_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles btnfive.Click

txtDisplay.Text = txtDisplay.Text & btnfive.Text

End Sub



Private Sub btnsix_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles btnsix.Click

txtDisplay.Text = txtDisplay.Text & btnsix.Text

End Sub

Private Sub btnseven_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles btnseven.Click

txtDisplay.Text = txtDisplay.Text & btnseven.Text

End Sub

Private Sub btneight_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles btneight.Click

txtDisplay.Text = txtDisplay.Text & btneight.Text

End Sub

Private Sub btnnine_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles btnnine.Click

txtDisplay.Text = txtDisplay.Text & btnnine.Text

End Sub

Private Sub cmdclear_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles cmdclear.Click

txtDisplay.Text = ""

End Sub
Private Sub period_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles period.Click

txtDisplay.Text = txtDisplay.Text +"."

End Sub




Private Sub cmdPlus_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles cmdPlus.Click
Dim Number1 as Double
Dim Number2 as Double
number1 = 0
Number2 = 0
number1 = number1 & txtdisplay.text
txtdisplay.text = ""




End Sub

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<p align="center">
<asp:TextBox id="Txtdisplay" runat="server"></asp:TextBox>
</p>
<p align="center">
<asp:Button id="btnseven" runat="server" Width="15px"
Text="7"></asp:Button>
<asp:Button id="btneight" runat="server"
Text="8"></asp:Button>
<asp:Button id="btnnine" runat="server"
Text="9"></asp:Button>
<asp:Button id="divide" runat="server"
Text="/"></asp:Button>
<asp:Button id="cmdclear" runat="server"
Text="c"></asp:Button>
</p>
<p align="center">
<asp:Button id="btnfour" runat="server"
Text="4"></asp:Button>
<asp:Button id="btnfive" runat="server"
Text="5"></asp:Button>
<asp:Button id="btnsix" runat="server"
Text="6"></asp:Button>
<asp:Button id="multiply" runat="server"
Text="*"></asp:Button>
</p>
<p align="center">
<asp:Button id="btnthree" runat="server"
Text="3"></asp:Button>
<asp:Button id="btntwo" runat="server" Width="15px"
Text="2"></asp:Button>
<asp:Button id="btnone" runat="server"
Text="1"></asp:Button>
<asp:Button id="cmdplus" runat="server"
Text="+"></asp:Button>
</p>
<p dir="ltr" style="MARGIN-RIGHT: 0px" align="center">
<asp:Button id="btnzero" runat="server"
Text="0"></asp:Button>
<asp:Button id="period" runat="server"
Text="."></asp:Button>
<asp:Button id="minus" runat="server"
Text="-"></asp:Button>
<asp:Button id="cmdequal" runat="server"
Text="="></asp:Button>
</p>
<!-- Insert content here -->
</form>
</body>
</html>
 
C

conspawn

yea how to code the plus button
i know it has to be something like this where am i going wrong?
Private Sub cmdPlus_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles cmdPlus.Click
Dim Number1 as Double
Dim Number2 as Double
dim MyService as New WebSCalculator.Calculator

If Session("Number1Entered") = "Y" then
Session("Number2") = txtdisplay.text

Session("Number1") =
System.Convert.ToString(MyService.Add(System.Convert.ToDouble(number1),system.Convert.ToDouble(number2))
)'Call your web method as it returns a double value back

Session("Number2") = ""
Session("Number1Entered") = "Y"
txtdisplay.text = Session("Number1") ' Show the answer returned
from your web method
End if
Session("Number1") = txtdisplay.text
Session("Number1Entered") = "Y"
Session("Number2") = ""
txtdisplay.text = Session("Number2") ' Clear the display so user
can enter number 2

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top