Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
So, I'm making an app in VB, it's an ATM. It starts off with a form, where you enter the PIN into the textbox, and it checks against the XML file, and if it's correct, it lets you in.

Code:
VB
Private Sub btnPINENTER_Click(sender As Object, e As EventArgs) Handles btnPINENTER.Click

    Dim AccountPIN As Integer

    Dim AccountName As String

    Dim InputPIN As Integer = Val(txtPIN.Text)

    Dim xelement As XElement = XElement.Load("Accounts.xml")
    Dim Records As IEnumerable(Of XElement) = xelement.Elements()

    For Each Account In Records
        AccountPIN = (Account.Element("PIN").Value)
        AccountName = (Account.Element("Name").Value)

        If InputPIN = AccountPIN Then

            MsgBox("Correct Password" & vbNewLine & "Welcome" & AccountName)
            Me.Hide()
            FrmATM.Show()
            txtPIN.Text = ""

        End If
    Next Account
End Sub


The next step is that the second form works like an ATM machine. So there are three buttons, Deposit, Withdraw and Account Balance. Now I need a way to be able to use the Deposit and WIthdraw buttons so that they can update the data in the XML File, but I'm clueless on how to do this. I'm a newbie as you can tell. Any help is greatly appreciated.

What I have tried:

I have tried re-working the code, but I have no idea how to actually use the app to write to the XML File.

I have asked multiple forums on Reddit and MSDN, but they give me answers for C+
Posted
Updated 7-Dec-18 17:39pm
Comments
Member 14081790 7-Dec-18 23:13pm    
Sorry, I should make it slightly clearer.

Basically, what I want to happen is that I press the Withdraw button, it uses the value in a Textbook, subtracts it from the value of <balance> in the XML file and then updates the value in the file, and then vice versa for Deposit.

In English:
Balance - TextBox = New Balance Value (this being the value that is updated)
Jim Meadors 7-Dec-18 23:41pm    
I just thought I should mention that if you are going to actually use this in some real production environment, you will also have to look up ways to encrypt your data.
Member 14081790 8-Dec-18 6:22am    
Yeah, no worries, it's only a school thing

1 solution

Google and download the LINQ Samples from Microsoft. There are over 100 samples that show you how to do great things with XML.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900