Results 1 to 5 of 5

Thread: How can I check if a Form is already loaded?

  1. #1

    Thread Starter
    Addicted Member Michel Jr's Avatar
    Join Date
    Jan 2000
    Location
    Brazil
    Posts
    175

    Question

    Hi,

    How can I check if a Form is already loaded?


    Thanks

    Michel Jr.

  2. #2
    Fanatic Member Stevie's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    565

    Thumbs up

    Hope this helps

    Code:
    Public Function FormIsOpen(strForm As String) As Boolean
    '***************************************************************************
    'Purpose:     Check if a given form is open or not.
    'Parameters:  strForm - Name of the form to check for.
    'Returns:     True/False - Form open?.
    '***************************************************************************
    
    Dim frm As Form
        
      FormIsOpen = False
      
      For Each frm In Forms
        If frm.Name = strForm Then FormIsOpen = True
      Next frm
    
    End Function

  3. #3
    New Member
    Join Date
    Jun 2000
    Location
    Canada
    Posts
    8

    Lightbulb Visible Property

    That's some neat code Stevie, but can't you just check the visible property of the form???

    if form1.visible = true then
    ' the form is already loaded
    end if

    Or would the form have to have focus for this to work?
    Just an idea.....
    Jonathan (Co President - Big Berdie International)
    Karl Moore RULEZ!
    "Pipers Do It With Amazing Grace!"

  4. #4
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    Big_Berdie,

    If the form you were testing the visible propert of was not loaded, it will be now.

    As soon as you refrecnce a property of the form, the form is loaded into memory. So Stevie's way is the way to do it.
    Iain, thats with an i by the way!

  5. #5
    Lively Member
    Join Date
    Jul 2000
    Posts
    72
    Plus a form can be loaded, but not visible. If you use the "Load Form" then form_load routine is run, but the form is not visible until the form.visble = true is run.

    VB 6 Professional Edition

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