By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,553 Members | 1,128 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,553 IT Pros & Developers. It's quick & easy.

Creating a ATM program

P: 7
OK, I am creating a program where I have two forms, the login and main form. On the login form the user will be prompted to enter their account number and password. This info is read from a file. Upon a successful login the main form will pop up with options to perform from there. I got it to where it will continue to the main form, but it gives me a error message every time. I am thinking I have the validation in the wrong spot. I'm sure I am just forgetting something. Also I was wanting to perform some type of encryption so no one could just open up the txt file and see the passwords in plain-text, I am completely lost when it comes to ideas on this one. And finally, once the users has entered in an account number/password three time I want it to terminate the program.
Expand|Select|Wrap|Line Numbers
  1. Public Class frmLogin
  2.     'Error message, how can I get rid of it
  3.     'Encrypt password, read it backwards
  4.     Dim sr As IO.StreamReader
  5.     Dim Acctnumber, password As String
  6.     Private Sub frmBankATM_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  7.         Me.Text = "RBD Bank Account Login"
  8.     End Sub
  9.  
  10.     Sub OpenFile()
  11.         sr = IO.File.OpenText("customers.txt")
  12.     End Sub
  13.     Sub CloseFile()
  14.         sr.Close()
  15.     End Sub
  16.  
  17.     Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
  18.         OpenFile()
  19.         Do While sr.Peek <> -1
  20.             Acctnumber = sr.ReadLine
  21.             password = sr.ReadLine
  22.             If txtaccount.Text = Acctnumber And txtpassword.Text = password Then
  23.                 frmMainboard.Show()
  24.             End If
  25.         Loop
  26.         OpenFile()
  27.         If sr.Peek <> -1 Then
  28.             MsgBox("The Account Number and/or Password Combination is Wrong", MsgBoxStyle.Critical, "Invalid Password")
  29.             Exit Sub
  30.         End If
  31.         CloseFile()
  32.     End Sub
  33. End Class
Nov 29 '07 #1
Share this Question
Share on Google+
1 Reply


P: 7
I got a little more done, still need a validation.
Expand|Select|Wrap|Line Numbers
  1. Public Class frmLogin
  2.     'Error message
  3.     'Only three Login attemps 
  4.     Dim sr As IO.StreamReader
  5.     Dim Acctnumber, password As String
  6.     Private Sub frmBankATM_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  7.         Me.Text = "RBD Bank Account Login"
  8.     End Sub
  9.  
  10.     Sub OpenFile()
  11.         sr = IO.File.OpenText("customers.txt")
  12.     End Sub
  13.     Sub CloseFile()
  14.         sr.Close()
  15.     End Sub
  16.  
  17.     Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
  18.  
  19.         OpenFile()
  20.         Do While sr.Peek <> -1
  21.             Acctnumber = sr.ReadLine
  22.             password = sr.ReadLine
  23.             If txtaccount.Text = Acctnumber And txtpassword.Text = Reverse(password) Then
  24.                 frmMainboard.Show()
  25.             End If
  26.         Loop
  27.     End Sub
  28.  
  29.     Function Reverse(ByVal info As String) As String
  30.         Dim a, b As Integer
  31.         Dim temp As Integer
  32.         Dim password As String = ""
  33.         a = info.Length
  34.         For b = a - 1 To 0 Step -1
  35.             temp &= info.Substring(b, 1)
  36.         Next
  37.         Return temp
  38.     End Function
  39. End Class
  40.  
Nov 29 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.