Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 8th, 2006, 11:39 AM
Registered User
 
Join Date: Jan 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default ATM Machine

I am trying to make an ATM-like program. I have 2 buttons, one to deposit $ and one to withdraw $. I also have a text box to enter the amount you want to deposit or withrdraw, as well as a current balance and new balance. My text box isn't working and a few other things seem out of place. I've been working on it and I'm close to finished I just need help finishing it off. Your help would be appreciated...if someone could correct my code.


<script runat="Server" language="VB">
Sub page_Load()
if Page.IsPostBack then
Dim intnewbal As Double
Sub Add(sender as object, e As EventArgs)
    newbal = newbal + CDbl(tbxInput1.text)
 lblAnswer.Text = newbal
Session ("newbal") = 0
End Sub
Sub Subtract(sender as object, e As EventArgs)
    newbal = newbal - CDbl(tbxInput1.text)
 lblAnswer.Text = newbal
Session ("newbal") = 0
End if
End Sub
 End Sub

</script>

<html>
<head>
<title>Your ATM Machine</title>
</head>
<body>
  <h1>Welcome to the ATM</h1><br/><br/>
<form id="BalanceForm" method ="post" action="bank.aspx runat="server">
  Current Balance: $
 <span id="bal">0</span>


<asp:textbox id="tbxInput1" runat="server" /><br/>
<asp:Button id="Add" OnClick="Add" runat="server" Text="Deposit Money"/><br>
<asp:Button id="Subtract" OnClick="Subtract" runat="server" Text="Withdraw Money"/><br>
New Balance : <%Session ("BalanceCount") %>


<input type="Submit">
  </form>

</body>
</html>
 
Old February 10th, 2006, 07:44 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You have subs inside of a sub. You can't do that.

Sub page_Load()
if Page.IsPostBack then
Dim intnewbal As Double
 End Sub
Sub Add(sender as object, e As EventArgs)
    newbal = newbal + CDbl(tbxInput1.text)
 lblAnswer.Text = newbal
Session ("newbal") = 0
End Sub
Sub Subtract(sender as object, e As EventArgs)
    newbal = newbal - CDbl(tbxInput1.text)
 lblAnswer.Text = newbal
Session ("newbal") = 0
End if
End Sub


-Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
Retore Db from a remote machine to a local machine srkvellanki BOOK: Beginning SQL 0 October 3rd, 2008 05:17 PM
ATM beginning program jrb47 ASP.NET 1.0 and 1.1 Basics 4 February 28th, 2008 06:49 PM
C programming ATM Machine mikie1112 C++ Programming 2 May 22nd, 2007 08:25 AM
Copy from one machine to another machine somnath.kartic SQL Server 2000 2 January 12th, 2006 03:13 PM
Atm program Pa_square C# 0 November 3rd, 2004 06:23 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.