Syntax to test if a form is open...


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Syntax to test if a form is open...

  1. #1
    Join Date
    Aug 2004
    Posts
    43,023

    Syntax to test if a form is open...

    [Originally posted by Don Brown]

    Does anyone know what the syntax would be for testing to see if a form is open?* I want to be able to ask if a user wants to save their data only if a form is open and has changes to it.

  2. #2
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Syntax to test if a form is open...

    [Originally posted by oliver bertrand]

    --Just use the .VISIBLE Method--

    Private Sub Command1_Click()

    If FORMNAME.VISIBLE = TRUE then
    * (stick code here)
    else
    * (do something else)
    end if

    Exit Sub

    It works for me, i set up 2 forms, 2 command buttons on form1.* One opens form2, the other checks to see if it is visible.* If you hide the forms or load them without showing, you may need to try some more indepth coding but this will generally work.* Hope it helps


  3. #3
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:Syntax to test if a form is open...

    [Originally posted by Don Brown]

    I assume it doesn't matter if the form is a child form within an MDI?

  4. #4
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Syntax to test if a form is open...

    [Originally posted by yoshi]

    try this code


    function IsFormVisible(FormName as string)boolean
    dim Frm as Form
    for each frm in forms
    * IsFormVisible=false
    * if frm.name = FormName and Frm.visible = true then
    * IsFormVisible=True
    * exit for
    end if
    next frm
    end funcion

    ''Usage

    if IsformVisible("FrmWhatEver")=true then
    'write your code here if visible
    else
    'write your code here if not
    endif

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center