|
-
Sep 26th, 2005, 09:37 PM
#1
Thread Starter
Member
[RESOLVED] Form Assistance
My project uses 5 forms and 3 of these forms need to be accessible to other forms. I have declared these forms as Public in a Code Module and am able to successfully access the properties and controls on the form.
When the app is first loaded, none of these forms are visible. When a user requires the form they simply click on a button and the form appears. After the user is done with the task on the "accesible form" my code hides the form.
The issue that I have is if I simply hide the form the values still exist and if I close the form I'm no longer able to open.
My resolution is to call a sub that clears all the controls and variables associated with these 3 forms.
My question is if there is a better way of clearing the form, so that I can simply do form.close and when the user needs the form it can reopen.
-
Sep 26th, 2005, 09:47 PM
#2
Re: Form Assistance
You could just do the .Close to destroy the form and clear everything. Then when you need it again you can re-instanciate it. This kind of defeats the need for it being public but it still depends on your app.
Instead of a .Show call you could call a custom procedure to clear and show so you dont have to remember to clear the form.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 26th, 2005, 09:51 PM
#3
Re: Form Assistance
In your module you can use something like this:
VB Code:
Public myForm1 As Form1
Public Sub ShowForm1()
If myForm1 Is Nothing OrElse myForm1.IsDisposed Then
myForm1 = New Form1
myForm1.Show()
Else
myForm1.Activate()
End If
End Sub
-
Sep 26th, 2005, 10:30 PM
#4
Thread Starter
Member
Re: [RESOLVED] Form Assistance
I appreciate the assistance. I have been struggling with that for the past 5 days. Now I can rest soundly
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|