FORM as variable

Discussion in 'AutoCAD' started by elefebvre, Apr 16, 2004.

  1. elefebvre

    elefebvre Guest

    Hi,

    I have several forms. When opened (initialized), they all have something similar happening, so I wrote a module that does this. The only thing i need now is to have the form as a variable sent with this module:

    public sub tag_test(Form1 as Forms)

    ...


    but this doesn't work. It gives me a type mismatch. I also tried MSForms and Form as datatyp but all give the same problem.

    I have tried to do it this way as well:

    Forms(0).tag = ...
    but when i check forms.count it gives me 0 in spite of the fact that the form is already opened and loaded

    any ideas on this?

    thanks in advance!

    Emmanuel
     
    elefebvre, Apr 16, 2004
    #1
  2. elefebvre

    Ed Jobe Guest

    Whenever you have a type mismatch, debug, and look in the Locals window or
    set a watch and the ide will tell you what type of object it is.

    --
    ----
    Ed
    ----
    similar happening, so I wrote a module that does this. The only thing i need
    now is to have the form as a variable sent with this module:
    and Form as datatyp but all give the same problem.
    form is already opened and loaded
     
    Ed Jobe, Apr 16, 2004
    #2
  3. This is how I do something like you want. (I think)

    Public objFormName As Object

    Public Sub UserForm_Initialize() 'sets up the cboScaleList ComboBox
    Set objFormName = Me
    ComboScaleFill
    End Sub

    Public Sub ComboScaleFill() 'different module
    objFormName.cboScaleList.AddItem "NTS"
    objFormName.cboScaleList.AddItem "" 'for a blank space
    objFormName.cboScaleList.AddItem "1'' = 1''"
    objFormName.cboScaleList.AddItem "3/4'' = 1''"
    objFormName.cboScaleList.AddItem "1/2'' = 1''"
    objFormName.cboScaleList.AddItem "3/8'' = 1''"
    objFormName.cboScaleList.AddItem "1/4'' = 1''"
    objFormName.cboScaleList.AddItem "3/16'' = 1''"
    objFormName.cboScaleList.AddItem "1/8'' = 1''"
    objFormName.cboScaleList.AddItem "3/32'' = 1''"
    objFormName.cboScaleList.AddItem "1/16'' = 1''"
    End Sub


    --

    Thanks,

    David M. Gardner
    Change the DOT to reply.
    similar happening, so I wrote a module that does this. The only thing i need
    now is to have the form as a variable sent with this module:
    and Form as datatyp but all give the same problem.
    form is already opened and loaded
     
    David M. Gardner, Apr 16, 2004
    #3
  4. elefebvre

    Ed Jobe Guest

    David, if you want to save some typing, try:
    With objFormName.ComboScaleList
    .AddItem
    .AddItem
    'etc.
    End With
     
    Ed Jobe, Apr 16, 2004
    #4
  5. Thank you for the reminder. I think I wrote that code before I learnd the
    "with" statement. I'm also sure I use the copy paste method. But I do like
    the "with".

    --

    Thanks,

    David M. Gardner
    Change the DOT to reply.
     
    David M. Gardner, Apr 16, 2004
    #5
  6. elefebvre

    A Seidel Guest

    Emmanuel,

    I'm not sure if this applies (trying to read into your end reason) but
    I use a different tactic when forms are similar. I use one form
    instead of multiple forms. The form looks at global variables within
    its own routines to determine what it should look like and how it
    should behave. There is much less maintenance with this approach.

    Allan
     
    A Seidel, Apr 16, 2004
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.