-1

When i run this code put a few items into lstF25 and press quit i dont get an error or anything but no xml file open can someone please help I havent done the other parts for the xml since i need to get this to work first if anyone has ever experienced this issue or knows anything about it and how to fix it your help would be greatly appreciated

Imports System.Xml
Public Class Form1
    Dim F25int As Integer = 0
    Dim F50int As Integer = 0
    Dim B25int As Integer = 0
    Dim B50int As Integer = 0
    Dim Fullname(7) As String
    Dim homeroom(7) As String
    Dim Event1(7) As String
    Dim F25I As Integer
    Dim F50I As Integer
    Dim B25I As Integer
    Dim B50I As Integer
    Dim xmlDoc As New XmlDocument()

    Dim writer As New XmlTextWriter("participants.xml", System.Text.Encoding.UTF8)
    Private Sub createNode(ByVal pEvent As String, ByVal pName As String, ByVal pHomeroom As String, ByVal writer As XmlTextWriter)

        writer.WriteStartElement("Participants")
        writer.WriteStartElement("Event")
        writer.WriteString(pEvent)
        writer.WriteEndElement()
        writer.WriteStartElement("name")
        writer.WriteString(pName)
        writer.WriteEndElement()
        writer.WriteStartElement("Homeroom")
        writer.WriteString(pHomeroom)
        writer.WriteEndElement()
        writer.WriteEndElement()

    End Sub
    Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click


        If chkF25.Checked Then
            lstF25.Items.Add(txtName.Text & " " & txtSurname.Text & " " & cmbHomeroom.Text)
            F25int = F25int + 1

        End If
        If chkF50.Checked Then
            lstF50.Items.Add(txtName.Text & " " & txtSurname.Text & " " & cmbHomeroom.Text)
        End If
        If chkB25.Checked Then
            lstB25.Items.Add(txtName.Text & " " & txtSurname.Text & " " & cmbHomeroom.Text)
        End If
        If chkB50.Checked Then
            lstB50.Items.Add(txtName.Text & " " & txtSurname.Text & " " & cmbHomeroom.Text)
        End If
    End Sub
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        cmbHomeroom.Items.Add("7.1")
        cmbHomeroom.Items.Add("7.2")
        cmbHomeroom.Items.Add("7.3")
        cmbHomeroom.Items.Add("7.4")
        cmbHomeroom.Items.Add("7.5")
        cmbHomeroom.Items.Add("7.6")
        cmbHomeroom.Items.Add("7.7")
        cmbHomeroom.Items.Add("7.8")
        cmbHomeroom.Items.Add("7.9")
    End Sub

    Private Sub btndeleteF25_Click(sender As Object, e As EventArgs) Handles btndeleteF25.Click
        lstF25.Items.Remove(lstF25.Text)
        F25int = F25int - 1
        F25()
    End Sub
    Private Sub F25()
        If lstF25.Items.Count > 0 Then
            lstF25.SelectedIndex = lstF25.Items.Count - 1
        End If
    End Sub
    Private Sub F50()
        If lstF50.Items.Count > 0 Then
            lstF50.SelectedIndex = lstF25.Items.Count - 1
        End If
    End Sub
    Private Sub B25()
        If lstB25.Items.Count > 0 Then
            lstB25.SelectedIndex = lstF25.Items.Count - 1
        End If
    End Sub
    Private Sub B50()
        If lstB50.Items.Count > 0 Then
            lstB50.SelectedIndex = lstF25.Items.Count - 1
        End If
    End Sub

    Private Sub btndeleteB25_Click(sender As Object, e As EventArgs) Handles btndeleteB25.Click
        lstB25.Items.Remove(lstB25.Text)
        B25int = B25int - 1

        B25()
    End Sub

    Private Sub btndeleteF50_Click(sender As Object, e As EventArgs) Handles btndeleteF50.Click
        lstF50.Items.Remove(lstF50.Text)
        F50int = F50int - 1

        F50()
    End Sub

    Private Sub btndeleteB50_Click(sender As Object, e As EventArgs) Handles btndeleteB50.Click
        lstB50.Items.Remove(lstB50.Text)
        B50int = B50int - 1

        B50()
    End Sub

    Private Sub btnQuit_Click(sender As Object, e As EventArgs) Handles btnQuit.Click
        F25I = F25int
        F25int = 0

        writer.Formatting = Formatting.Indented
        writer.Indentation = 2
        writer.WriteStartElement("Participants")
        Do While F25int < F25I
            createNode(Event1(F25int), Fullname(F25int), homeroom(F25int), writer)
            F25int = F25int + 1
        Loop
        writer.WriteEndElement()
        writer.Close()
        writer.Close()
        xmlDoc.Load("participants.xml")
        End
    End Sub
End Class

When i run this code put a few items into lstF25 and press quit i dont get an error or anything but no xml file open can someone please help

4
  • The only load I see is in the last button btnQuit. Commented Mar 12, 2024 at 13:04
  • The following may be of interest: stackoverflow.com/questions/73638292/… Commented Mar 12, 2024 at 16:21
  • Here are some more: stackoverflow.com/a/68513150/10024425 and stackoverflow.com/a/71095489/10024425 Commented Mar 12, 2024 at 16:23
  • Repeating the same content to bypass the minimum content length is a violation of the site guidelines. It's also an insult to the millions of people here that take the time to ask decent questions, as well as the millions of others who volunteer their time to answer those questions. The minimum length requirement is part of the quality control here, and if you're not allowed to post your question because that text is not there, then you've not done well enough explaining the problem. Commented Mar 20, 2024 at 0:40

1 Answer 1

-1

all i had to do was change xmlDoc.Load("participants.xml") to process.start("participants.xml")

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.