unload userform

Discussion in 'AutoCAD' started by Hartmut Callies, Jul 23, 2004.

  1. Hello,
    I have in autocad 2004dx a simple userform frmT1 with a commandButton
    "Cancel".
    With the button I must unload the userform.

    Private Sub cmdCancel_Click()
    Unload frmT1
    End Sub

    I get a error! Why?
     
    Hartmut Callies, Jul 23, 2004
    #1
  2. Hartmut Callies

    DaleB Guest

    You can't unload a form while it is still active.
    Try:

    Private Sub cmdCancel_Click()
    Me.Hide
    Unload frmT1
    End Sub
     
    DaleB, Jul 23, 2004
    #2
  3. Hartmut Callies

    Norman Yuan Guest

    Why H.C. got error is a strange thing (if he could give more detail, or post
    all his code, it may become clear), but, I never heard that you have to hide
    it before unloading a form. No hiding is necessary. Yu can directly call

    Unload theForm
    or
    Unload Me
     
    Norman Yuan, Jul 24, 2004
    #3
  4. Hartmut Callies

    noone Guest

    Well Norman, I am not even close to being any kind of an expert, but my "VBA
    for Dummies" book says that the form has to be hidden first. Modal forms
    cannot be unloaded while they are active.

    Have you been able to make it work without first hiding it?
     
    noone, Jul 24, 2004
    #4
  5. Hartmut Callies

    Mark Propst Guest

    have you tried
    ???
     
    Mark Propst, Jul 24, 2004
    #5
  6. Hartmut Callies

    Norman Yuan Guest

    That "VBA for Dummies" is deadly wrong, at least in the case of AutoCAD VBA
    (it could be right for "VBA" implemented in particular application, but I
    think it is quite unlikely, unless the "VBA" is not from Microsoft, I have
    been programming VB/VBA quite some time and never heard of that).

    Just start new UserForm in AutoCAD, put a button on it, double-click it into
    code window, write following code:

    Private Sub CommandButton1_Click()
    Unload Me
    ''''Or you can
    ''''Unload UserForm1
    End Sub

    Run it so that the form is shown, and then click the button. Surperise: the
    form is gone: unloaded.
     
    Norman Yuan, Jul 24, 2004
    #6
  7. Hello,
    thanks for your help!
    I have test it. When I have a new project with a userform and button
    "cancel"
    with code:
    Private Sub cmdCancel_Click()
    Unload frmT1
    End Sub
    No error!

    When I use the object "Microsoft Scripting Euntime" object (scrrun.dll) to
    select
    files then I get error when I click on the button.

    translation from german:
    "compile-error
    wrong number argument or invalid assign to a property"

    The command frmT1.Hide not help.

    Have anyone a idea?

    Hartmut Callies
     
    Hartmut Callies, Jul 26, 2004
    #7
  8. Hartmut Callies

    noone Guest

    I think I need to apologize to this group and to the authors of my "VBA for
    Dummies" book. After the exchange in this discussion group I pulled out the
    book to check my facts and I see now that I misinterpreted what they had
    written. They did not make the error I attributed to them, that was
    entirely my mistake - I simply read it over too quickly without thinking
    about what I actually read. Sorry to all for any harm done.
     
    noone, Jul 28, 2004
    #8
  9. Well, that was nice of you. Kudos for being humble enough to post that.

    --
    R. Robert Bell


    I think I need to apologize to this group and to the authors of my "VBA for
    Dummies" book. After the exchange in this discussion group I pulled out the
    book to check my facts and I see now that I misinterpreted what they had
    written. They did not make the error I attributed to them, that was
    entirely my mistake - I simply read it over too quickly without thinking
    about what I actually read. Sorry to all for any harm done.
     
    R. Robert Bell, Jul 28, 2004
    #9
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.