Community discussion forum
Forms
-
This thread is for discussions of Forms.
-
Advertisement
Simply the fastest line-level profiler for .NET ever
“The low overhead means it has minimal impact on the execution of my program”
Mark Everest, Development Team Leader, Renault F1 Team Ltd.Try out the new ANTS Profiler 4 for yourself. Download your 14-day trial now
-
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
-
You use the
Code: statement, as mentioned onUnload theForm
-
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 -
I cannnot get the inner form width on a Mdi form expanded to more than normal screen resolution.
-
Im very new at VB, and I just need to know how to make a
>>Button to Link to another Form<<
Please Help! -
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 -
5 years agoby
Thushan Fernando
Thushan Fernando
Australia :: Melbourne, AustraliaJoined 7 years agookay, 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:
FormLoad()
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 FormLoad() 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? -
If you replace "vbModeless" with "vbModal" then no window below can be clicked on! Great for setting options.
-
i know an even simpler method:
Code:
Public Sub CloseAll()
End
End Sub
it works fine for me
-
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...
-
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
-
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 a reply
Quick links
Recent activity
- Thomas no replied to Send images through Shell("...
- Mandy Bradley replied to Loop help needed
- Chris Hsu replied to How can I execute server-si...
- anu anand.lv replied to Excel Oledb Engine and VB.NET
- Rafeeque Ahmed replied to HELP ME, URGENT RESPONSE
- anu anand.lv replied to we search the company in I...
Enter your message below
Sign in or Join us (it's free).