Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

[72] Forms

Last post 07-02-2005 5:09 PM by Bomb3rman. 12 replies.
Page 1 of 1 (13 items)
Sort Posts: Previous Next
  • 01-01-1999 12:00 AM

    [72] Forms

    This thread is for discussions of Forms.

    • Post Points: 0
  • Advertisement

    • Red Gate Software

    Advertisement

    Want to boost your .NET application performance?

    Some developers always seem to write efficient and lightening-fast code. What is their secret? It’s ANTS Profiler. “We improved the performance of the application up to 10 times” Dan Ports, Intrigma.

    Try it for yourself now.

  • 03-08-2002 2:16 PM In reply to

    • po8freak
    • Not Ranked
    • Joined on 03-08-2002
    • New Member
    • Points 30

    Missed a BIG note on forms

    You mensioned that loaded forms take memory, but never mension how to close them all when your program ends. Probably the FIRST thing you need to learn if your application uses more then one form. Visual Basic does Not nessasarily release this memory otherwise, I know
    • Post Points: 0
  • 03-08-2002 2:55 PM In reply to

    • James Crowley
    • Top 10 Contributor
    • Joined on 12-07-2000
    • United Kingdom
    • Guru
    • Points 15,030
    • SystemAdministrator
    • Post Points: 0
  • 03-08-2002 3:21 PM In reply to

    • Lio_889
    • Top 500 Contributor
    • Joined on 10-03-2001
    • Addicted Member
    • Points 455
    Check out the following code: Code:
    Public Sub CloseAll()

    Dim frmForm As Form
    On Error Resume Next
    'close all forms
    For Each frmForm In Forms
       Unload frmForm
    Next
    End

    End Sub
    • Post Points: 0
  • 08-09-2002 1:26 PM In reply to

    ScrollBars

    I cannnot get the inner form width on a Mdi form expanded to more than normal screen resolution.
    • Post Points: 0
  • 02-24-2003 3:41 AM In reply to

    Im a Newbie

    Im very new at VB, and I just need to know how to make a

    >>Button to Link to another Form<<

    Please Help!
    • Post Points: 0
  • 03-27-2003 5:43 PM In reply to

    Say your button is command1, then, if you mean what I think you mean:

    Private Sub command1.Click()
    form1.hide
    form2.show
    end sub

    Simple enough to understand. You can use .load and .unload rather than .show and .hide to make the program use less memory, but it'll be slower (and I'm having trouble getting .unload to work).
    [edit] Aha, here it is. To use the more RAM-friendly but slower load/unload, you would do this:
    unload form1
    load form2

    Strange how form1.load didn't cause an error, but .unload did. O_o
    • Post Points: 0
  • 03-27-2003 7:22 PM In reply to

    okay, we'll welcome to the both of you.

    To show a form, you can do it in a few ways.

    If you want to show aform and stop the process from being able to execute any more comments until the form is close we would do this:

    frmForm.Show vbmodal

    what that means is say this scenario:
    Code:

    Form_Load()
    on error goto ErrH
    dim i as integer
    i = 1000
    i = i / 0
    errH:
    frmForm.Show vbmodal
    Resume Next
    end sub

    now that will cause a 'Divide by Zero' error when you run it because of the i=i/0 line. We are using Eroror handling(first line under the Form_Load() statement) so it will goto the ErrH: area and execute what ever is underneath it. By running it in a Modal state we will stop the excution of commands until the form is dismissed by the user.

    Now what if you didnt want to show the form and stop executing? Simple use the .Show method on the form.

    Okay i hear you say "Okay smarty pants.. what if i want to float the form ontop of a form?(Eg. Form1 ontop of Form2?) huh? Huh? think you so smart try that one? come on comone? huh... wanna start me now? huh?"...

    we'll no need to get so jumpy... we simply do this: form1.show , form2 where Form2 is the parent form of form1!

    now when your unloading you forms its important to unallocate the memory that the form may be occupying. You can achieve this by this:

    Code:

    {rivate sub Form_Unload(cancel as integer)
    On error resume next '// Just incase
    set <form name> = nothing '// unallocatoin
    End sub


    As for loading and unloading as HyperHacker has said... you would use that if your intending to load a form prior to showing it, typical scenario is when you display a Splash screen, in the background all the forms are being loaded(yes theres a reason for the Splash screen and its not just for nice logos!)...

    Does this help?
    Digitally Yours,

    Thushan Fernando
    • Post Points: 0
  • 05-31-2003 2:11 AM In reply to

    • Knoj
    • Not Ranked
    • Joined on 05-30-2003
    • New Member
    • Points 10

    Your answer pointed me to mine!

    If you replace "vbModeless" with "vbModal" then no window below can be clicked on!  Great for setting options.
    • Post Points: 0
  • 02-17-2005 1:19 PM In reply to

    • jawsper
    • Not Ranked
    • Joined on 04-11-2003
    • Junior Member
    • Points 25
    i know an even simpler method:

    Code:

    Public Sub CloseAll()
       End
    End Sub


    it works fine for me
    ----------------------------------
    so, why arent you reading my extremely interesting post above? ;)
    • Post Points: 0
  • 02-17-2005 1:38 PM In reply to

    • James Crowley
    • Top 10 Contributor
    • Joined on 12-07-2000
    • United Kingdom
    • Guru
    • Points 15,030
    • SystemAdministrator
    You don't really want to use End, as it forcefully terminates everything, rather than gracefully telling the forms that they're about to be closed (ie the Unload event), and then removing them from memory...
    • Post Points: 0
  • 02-17-2005 2:37 PM In reply to

    • jawsper
    • Not Ranked
    • Joined on 04-11-2003
    • Junior Member
    • Points 25
    true, i noticed that my tray icon doesnt disappear automatically, cause the unload method of the form its on isnt loaded...

    ah well it works fine if you need to really kill it i guess
    ----------------------------------
    so, why arent you reading my extremely interesting post above? ;)
    • Post Points: 0
  • 07-02-2005 5:09 PM In reply to

    End a sub in another form

    In my program I have two forms. The user is asked to input a number in my custom-made form (input box) which has "OK", "CANCEL" and the input textbox.

    Basically the problem is if if the user presses "Cancel" in my custom input box, the sub in the first form will just continue being played out when I want to pretty much "cancel" it. How can I make the "cancel" button in my second form make the sub in the first form end?

    Thanks!
    • Post Points: 0
Page 1 of 1 (13 items)