Results 1 to 11 of 11

Thread: [RESOLVED] If Statement Help

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2006
    Posts
    83

    Resolved [RESOLVED] If Statement Help

    Hi, another dorky question from me.

    Using VB 6

    -------------------------------------

    I would like to use an "If" statement to handle
    the loading & showing of a form.

    Something like:

    Private Sub HandleForm()

    Load Form1

    If ***Form1 has completely loaded*** Then
    Form1.Show

    End Sub

    -------------------------------------

    I'm want to handle a form in this manner, because my program will be executing other stuff while Form1 is loading.

    Thanks!!!

  2. #2
    Member
    Join Date
    Aug 2004
    Posts
    35

    Re: If Statement Help

    VB Code:
    1. if isloaded
    ....

  3. #3
    Lively Member
    Join Date
    Jul 2006
    Posts
    119

    Re: If Statement Help

    Hello!


    VB Code:
    1. Private Sub Form_Handle()
    2.  
    3. if form1.visible = true then
    4.  
    5. show form2
    6.  
    7. End Sub

    Do you mean soming like that ! ?

  4. #4
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: If Statement Help

    Try this:
    VB Code:
    1. 'start checking for "is loaded"
    2. Private Sub Command1_Click()
    3.     Do Until isLoaded("Form1") = True
    4.         'do your thing
    5.             DoEvents
    6.     Loop
    7.         Form1.Show
    8. End Sub
    9.  
    10. 'load it - Form1 should show after you click this
    11. 'and after Form1 is in the Forms collection
    12. Private Sub Command2_Click()
    13.     Load Form1
    14. End Sub
    15.  
    16. Private Function isLoaded(frm As String) As Boolean
    17.     Dim f As Form
    18.         For Each f In Forms
    19.             If f.Name = frm Then
    20.                 isLoaded = True
    21.                     Exit Function
    22.             End If
    23.         Next
    24. End Function

  5. #5
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: If Statement Help

    I'm a little confused about the statement.. as long as you don't have WindowState set as Minimized, it should show itself automatically...

  6. #6
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    Re: If Statement Help

    Quote Originally Posted by timeshifter
    I'm a little confused about the statement.. as long as you don't have WindowState set as Minimized, it should show itself automatically...
    Load FormName will not automatically show the form. Load only loads the form into memory it doesn't show it. You will have to call show to activate it.

  7. #7
    Hyperactive Member
    Join Date
    Oct 2006
    Location
    USA
    Posts
    476

    Re: If Statement Help

    Quote Originally Posted by MarkT
    Load FormName will not automatically show the form. Load only loads the form into memory it doesn't show it. You will have to call show to activate it.
    If you use Load FormName, will it execute the code in the Form_Load event? (I'm thinking it will, just want to be sure.)

  8. #8
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: If Statement Help

    Quote Originally Posted by disruptivehair
    If you use Load FormName, will it execute the code in the Form_Load event? (I'm thinking it will, just want to be sure.)
    Yes... btw, is this so hard to try? You create 2 forms, add MsgBox "Can you see me?" in one's Form_Load event and load it from the other

  9. #9
    Hyperactive Member
    Join Date
    Oct 2006
    Location
    USA
    Posts
    476

    Re: If Statement Help

    Quote Originally Posted by gavio
    Yes... btw, is this so hard to try? You create 2 forms, add MsgBox "Can you see me?" in one's Form_Load event and load it from the other
    Sorry gav, you're right; it wouldn't be hard to try if I was at the office where I have access to VB instead of at home where I don't.

  10. #10
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: If Statement Help

    Quote Originally Posted by disruptivehair
    Sorry gav, you're right; it wouldn't be hard to try if I was at the office where I have access to VB instead of at home where I don't.
    It's been about 20 hours since i'm up... i should get some rest... i'm gettin' a bit "kranky"

  11. #11
    Hyperactive Member
    Join Date
    Oct 2006
    Location
    USA
    Posts
    476

    Re: If Statement Help

    Quote Originally Posted by gavio
    It's been about 20 hours since i'm up... i should get some rest... i'm gettin' a bit "kranky"
    Yeah, you should get some sleep...and I'm sure if I look at my posts a year from now I'll probably roll my eyes.

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