NEED HELP WITH CALCULATOR WEB SERVICE

Discussion in 'ASP .Net Web Services' started by conspawn, May 24, 2005.

  1. conspawn

    conspawn Guest

    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>
    conspawn, May 24, 2005
    #1
    1. Advertising

  2. conspawn

    Scott M. Guest

    Did you want to tell us exactly what "difficulties" you were having?


    "conspawn" <> wrote in message
    news:...
    > 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>
    >
    Scott M., May 24, 2005
    #2
    1. Advertising

  3. conspawn

    conspawn Guest

    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
    conspawn, May 25, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Maria Laura Re

    URGENT Help With Scientific Calculator!

    Maria Laura Re, Dec 13, 2003, in forum: Java
    Replies:
    4
    Views:
    505
    Andrew Thompson
    Dec 14, 2003
  2. Rafael

    Need help with my Calculator program.

    Rafael, Dec 2, 2003, in forum: C Programming
    Replies:
    6
    Views:
    388
    osmium
    Dec 4, 2003
  3. Yonih
    Replies:
    2
    Views:
    570
    Andrew Thompson
    Sep 10, 2008
  4. Leo Violette
    Replies:
    0
    Views:
    1,000
    Leo Violette
    Apr 17, 2009
  5. Yonih
    Replies:
    4
    Views:
    116
    Yonih
    Jun 25, 2008
Loading...

Share This Page