• Class and Userforms (2000 SR1)

    Author
    Topic
    #369725

    WIthin an Excel Addin I have a Class that performs some file IO. The actions and locations for the IO performed are determined by input from the user via a UserForm. What is the best way to handle gathering the input from the UserForm to be used by the Class object?
    I have tried within the class to create a new instance of the form
    Dim frm as frmUserForm
    Set frm = New frmUserForm

    The problem is that this new instance of the form does not have the same methods and properties as the form I created within the VBE. Ther is no Show property or method so I have been unable to get the new instance of the form to appear.

    Thanks

    Viewing 0 reply threads
    Author
    Replies
    • #582897

      Hi,
      Without knowing the specifics of your add-in it’s a little hard to know what you need, but I would have generally thought that the easiest way of doing something like this would be to have your addin run a simple frmYourUserformName.Show line and then have a command button on your userform that creates an instance of your class and assigns the relevant control values to the various properties of your class – e.g.
      clsWhatever.Path = me!txtPath
      clsWhatever.FileName = Me!txtFilename
      clsWhatever.ReadData
      Does that help?

      • #582955

        You are right! I was looking at it from the opposite direction. So what you are saying is to have the UserForm call and use the Class object instead of the Class calling and using the UserForm. That would definately resolve this problem. However, how would you handle a similiar scenario where a Class uses several UserForms?

        Thanks Again!
        Ed

        • #582963

          Hi,
          You would use the frmUserformName.Show syntax as before within the relevant procedure in your class module.
          Hope that helps.

        • #582967

          No, just have the class module display the user form using:

              frmUserformName.Show
          
          • #582971

            So when displaying a UserForm within a Class you would not create a new instance of the form such as:
            Dim fmrNew as frmUserForm
            Set frmNew = New frmUserForm
            …And instead do the following:
            frmUserFrom.Show

            Thanks
            Ed

    Viewing 0 reply threads
    Reply To: Class and Userforms (2000 SR1)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: