通过visual basic编辑XML文件 [英] Edit an XML file through visual basic

查看:98
本文介绍了通过visual basic编辑XML文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我正在用VB制作应用程序,它是一台ATM。它从一个表单开始,您在其中输入PIN到文本框中,它会检查XML文件,如果它是正确的,它会让您进入。



代码:

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:

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





下一步是第二种形式就像一台ATM机。所以有三个按钮,存款,提款和账户余额。现在我需要一种方法来使用Deposit和WIthdraw按钮,以便他们可以更新XML文件中的数据,但我对如何执行此操作毫无头绪。你可以告诉我,我是新手。非常感谢任何帮助。



我尝试过:



我试过重新编写代码,但我不知道如何实际使用该应用程序写入XML文件。



我在Reddit上问了多个论坛和MSDN,但他们给我答案C +



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+

推荐答案

谷歌并从微软下载LINQ样本。有超过100个样本向您展示如何使用XML做出很棒的事情。
Google and download the LINQ Samples from Microsoft. There are over 100 samples that show you how to do great things with XML.


这篇关于通过visual basic编辑XML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆