Results 1 to 10 of 10

Thread: Both work, but is one better?

  1. #1

    Thread Starter
    Member JPRoy392's Avatar
    Join Date
    Aug 2000
    Posts
    50

    Question

    When I want my program to show a new form I can either use:

    Form1.Visible = True
    or
    Form1.Show

    Both work interchangably in my program and seem to have the same effects on the data I was just wondering if one was better.

    Thanks
    Jim

    "...head is all empty and I don't care..."

  2. #2
    Addicted Member S@NSIS's Avatar
    Join Date
    Aug 2000
    Location
    Stoke-On-Trent, England
    Posts
    243
    Hi,
    Form.Show is better than Form.visible=True:

    When you unload a form it is cleared from memory thus freeing up resources, you then use form.show to load it back up again. However if you just use form.visible=true/false, then the form is always in the memory whether it is visible or not.

    hope this helps

    Shaun
    Web/Application Developer
    VB6 Ent (SP5), Win 2000,SQL Server 2000

  3. #3
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Actually none is better because they have 2 different functions, Show Loads AND displays them, Visible = True only displays it.

    S@nsins is right about loading and stuff, but if you need to make a form invisible for a very short time (making a snapshot of the things below your prog) it would be better to use Form2.Visible = False, make the snapshot, Form2.Visible = True
    This would result in a faster way then Unload Form2, make snapshot, Form2.Show
    Know what I mean?

    But anyway, to load a form the first time you need to show it with Form.Show, and don't forget to Unload it, don't use End because it's a brute way to quit a program! (not saving, no Unloading from memory, no closing files and ...)
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  4. #4
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    Actually, they're both the same.
    If Form1 isn't loaded, and you want its Show function, VB loads it and then runs the Show function.
    All this function does (with default parameters) is change the Visible to True.
    Of course the form is loaded, otherwise the function would be inaccessible.
    Also, Form1.Visible = True loads the form if it's not loaded, because otherwise the Visible property is inaccessible.

  5. #5
    Guest
    Is show.visible = false the same as frm.hide?

  6. #6
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    Show.Visible = False? That's a runtime error!
    Code:
    MyForm.Visible = False
    ' Is equivalent to:
    Call MyForm.Hide
    ' If MyForm isn't loaded, the above two examples are also equivalent to:
    Call Load(MyForm)

  7. #7
    Guest

    Smile

    Thanks Yonatan, how did you know what I really meant?

  8. #8
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    Wisdom, knowledge, experience, skills.
    (P.S. I guessed)

  9. #9
    Lively Member
    Join Date
    Aug 2000
    Location
    Ontario, Canada
    Posts
    79
    Actually, from what I believe, a form is still in memory until you set it's instance to nothing. Even if you are just using the name of the form instead of a new instance you should set it to nothing:

    Eg:

    Code:
    frmMain.Show
    Unload frmMain
    Set frmMain = Nothing

  10. #10
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    Originally posted by Yonatan
    Wisdom, knowledge, experience, skills.
    (P.S. I guessed)
    how old are you Yonatan?


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