Results 1 to 3 of 3
  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2012

    vb6 - User-defined type not defined


    I am trying to modify a pre-written program by others. I copy the original form frmMain to frmMain2.

    But when I compile this code for frmMain2 that I copied, I got error message user-defined type undefined. the code is as follow:

    Private Sub Form_Load()

    LoadAlarms mAlarmCollection
    End Sub

    //XMLStorage Module
    Public Sub LoadAlarms(ByRef AlarmCol As Collection)
    Dim xmlDoc As DOMDocument <---the error here
    Dim i As Long
    Dim nodeAlarms As IXMLDOMElement
    Dim nodeAlarm As IXMLDOMElement
    Dim oAlarm As clsAlarmSetting

    Set AlarmCol = New Collection

    End Sub

    It works fine with original frmMain, but does not work with frmMain2.

    When I debug, frmMain does not go to DIm xmlDoc, but go stratight to SetAlarm = New Collection.

    But when i debuf frmMain2, it goes to Dim xmldoc and error occurs.

    Is there anything that i missed out? how do i define DOMDocument?


  2. #2
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Searching for mendhak

    Re: vb6 - User-defined type not defined

    Go back to the first project.

    Click on Project/References.

    You will see things in there that are checked that you don't have checked in the second project.

    DOMDocument is not a built in data type. It requires an external reference to be added to the project.

    The first project has that reference, the second project doesn't.

    Without that reference, you would get the same error on:
    Dim nodeAlarms As IXMLDOMElement
    Dim nodeAlarm As IXMLDOMElement
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2012

    Re: vb6 - User-defined type not defined

    Thanks hack! it works!

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

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.