Results 1 to 2 of 2

Thread: Sharing xmlDocument between forms - Help!

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2000
    Location
    Dayton, OH USA
    Posts
    119

    Sharing xmlDocument between forms - Help!

    I need to share the xmlDocument object between forms, if possible:


    Form 1 or frmMain:

    Public doc As New XmlDocument()

    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Try
    doc.Load(xmlPath)
    Call FillServerList()
    Catch ex As Exception
    MessageBox.Show(ex.Message)
    End Try
    End Sub

    Form 2:

    Dim MainForm As frmMain

    Dim xmlroot As XmlElement = MainForm.doc.DocumentElement

    Get an object not referenced error. Any help would be greatly appreciated. If I can do this I can prevent from having to load multiple copies of the same xml file into memory

  2. #2
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    Declare it as shared in a module, then you'll be able to access it from any form.
    Dont gain the world and lose your soul

Posting Permissions

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



Click Here to Expand Forum to Full Width