|
-
May 18th, 2005, 07:47 PM
#1
Thread Starter
Lively Member
-
May 18th, 2005, 07:56 PM
#2
Re: Form close and re-show problems.
Two things. One, when you defined the form frmQ1 you probably instanciated it with something like
"Public frmQ1 As New frmQ". When you .Dispose of the form by way of the .Close method, your
destroying the instance of frmQ1.
To fix that, yes, you just do a .Hide/.Show or create a new instance of it when you need to show it again, like I just coded. 
This will take care of #2 but if your always destroying/creating the same form then its better on resources and performance if you .Hide/.Show.
Now this brings up issue #2 again. To get around that, you need to re-code the load event so things happen differently
rather then relying on the load event.
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 
-
May 18th, 2005, 09:25 PM
#3
New Member
Re: Form close and re-show problems.
Hi martw,
Whenever I open a form in a project, I use the following approach:
In this example, the name of my form is Window
VB Code:
' First declare the object
Dim objWindow as New Window
' Now insert the following after an event to open the form
If Not objWindow Is Nothing Then
If objWindow.Created = True Then
objWindow.Show()
objWindow.Activate()
Else
objWindow = New Window
objWindow.Show()
objWindow.Activate()
End If
End If
With this code, you can close forms or hide them; either way thay should open correctly.
NPath
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
|