dcsimg
Results 1 to 4 of 4

Thread: ATM program

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2011
    Posts
    14

    ATM program

    I've completely written an ATM program with a few forms that do everything from greet, take your PIN, and go through the basics (withdrawal, deposit, transfer, balance inquiry). Now, currently it is set to one valid PIN and static balances for checking and savings of $1,000 every time you start the program and does all the necessary checking as you withdrawal and such to be sure valid amounts are entered and the accounts have sufficient funds. Which brings me to my question:

    How would I go about making it multi-user utilizing a sequential access file?

    I have very little knowledge of this process thus far with simple memory games or reading the .txt file to produce a list box.

    I know how to create the file, the format to use (111,1000,1000 as PIN,CheckingBalance,SavingsBalance) and I could incorporate it in the rest of the program if I could just get the basics of how to:

    Read the PIN, search the txt file for the PIN to be sure it's there and valid and then read that account's info for the duration of the program AND write the new values to the txt file.

    Code:
    Public Class PINform
        Private Sub acceptButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles acceptButton1.Click
            'check PIN
            If pinTextBox.Text = "111" Then
                Me.Hide()
                MainForm.Show()
            Else
                If gCounter < 2 Then
                    MessageBox.Show("Please enter a valid PIN.")
                    gCounter += 1
                    pinTextBox.Text = String.Empty
                Else
                    'terminate program after third incorrect PIN
                    MessageBox.Show("Too many illegal attempts. Try again later.")
                    Me.Close()
                End If
            End If
        End Sub
    End Class
    Not sure if this helps, but this is just the Welcome Screen / PIN entry form. After three unsuccessful attempts the program terminates.

    Yes, the program I have already written is a school project but it is already done perfectly (by the assignment's standard). I would just really love to know more about this accessing/writing/searching with the txt files.

    Thanks in advance for reading my long-winded post and any help is greatly appreciated.

    (Yes, I tried searching for such things already and only stumbled upon people using Access instead of the txt files.)

  2. #2

    Thread Starter
    New Member
    Join Date
    Apr 2011
    Posts
    14

    Re: ATM program

    No love.

  3. #3
    Addicted Member cellus205's Avatar
    Join Date
    Dec 2010
    Location
    San Antonio, TX
    Posts
    237

    Re: ATM program

    What format is the text file in? You'd use a StreamReader to read the text file to a stream, and then from there you can parse the stream to organize it or read it into a workable format

  4. #4

    Thread Starter
    New Member
    Join Date
    Apr 2011
    Posts
    14

    Re: ATM program

    Quote Originally Posted by cellus205 View Post
    What format is the text file in? You'd use a StreamReader to read the text file to a stream, and then from there you can parse the stream to organize it or read it into a workable format
    It's just a normal .txt.

    So, the StreamReader, wouldn't that mean I'd have to load every line of the document to memory then search it for the PIN to get the account info?


    I was thinking something like the whole:

    fileContents= _
    My.Computer.FileSystem.ReadAllText(file)
    newLineIndex = fileContents.IndexOf(ControlChars.NewLine)


    Something like that. Is there not a way to handle it sequentially accessing the file while searching? Then after PIN is found, something like uh...

    gCheckingAccount = _
    fileContents.Substring(numIndex, newLineIndex - numIndex)

    Then again, I wouldn't be asking if I knew, I just figured there was some way to do it simply using sequential access to the .txt.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width