Results 1 to 5 of 5

Thread: Very simple, object name......................:)

  1. #1

    Thread Starter
    Fanatic Member wildcat_2000's Avatar
    Join Date
    Nov 2000
    Location
    Italy
    Posts
    727
    Hi all,

    could you please someone help me out here, this IS simple, just an object definition that I cannot find.

    I've got an MDI form, in which a button creates new forms with this code:

    Code:
    Dim frmA As Main
    Set FrmA As New Main
    FrmA.Show
    Main is the name of a template form that I use to create all the forms within the MDI.

    Now, how can I retrieve the Height property of one of these child forms? I need the object name, i.e. if I need the height of Main I use Main.Height, but in this case what can I use? FrmA.Height within a code doesn't work. I believe something as Parent.Height should exist, if someone knows the right expression

    Thank you very much in advance,

    W.
    When your car breaks down,
    close all windows and retry

    => please rate all users posts! <=

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    You have your variable setup wrong. If you want to create an instance of the form with Set statement, the you should do something like this:

    Set frmA = New Main

    Since you have an object variable that represents your form, you can treat it just like a regular form.
    Code:
    Dim frmA As New Main
    
    frmA.Show
    
    MsgBox frmA.Height

  3. #3

    Thread Starter
    Fanatic Member wildcat_2000's Avatar
    Join Date
    Nov 2000
    Location
    Italy
    Posts
    727
    No ok my variable is correct, just the code that I typed here was wrong

    Thanks for your answer, but the problem still remains, as it is NOT when I create the new form that I need to know the height, but at a further moment by clicking on a button on the form itself.
    When your car breaks down,
    close all windows and retry

    => please rate all users posts! <=

  4. #4
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    On the button's click event you can do something like this:
    Code:
    Private Sub Command1_Click()
        MsgBox Me.Height
    End Sub
    This should work regardless how many instances of your form you have created.

  5. #5

    Thread Starter
    Fanatic Member wildcat_2000's Avatar
    Join Date
    Nov 2000
    Location
    Italy
    Posts
    727

    ... I thought that too!

    Yes, that was the first thing that I did try... but it didn't work I'm sorry I can't recall what the problem was, anyway Me was not interpreted as a valid object, who knows why...

    Thanks for all your replies, I hope you have other suggestions!

    Best regards,

    W.
    When your car breaks down,
    close all windows and retry

    => please rate all users posts! <=

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