|
-
Jul 16th, 2003, 09:18 PM
#1
Thread Starter
^:^...ANGEL...^:^
UNLOAD forms.
OK whats is the equivelant of this code from VB 6 to VB.NET.
VB Code:
Dim frm As Form
For Each frm In Forms
Unload frm
Set frm = Nothing
Next frm
-
Jul 16th, 2003, 11:01 PM
#2
In .NET there is no intrinsic Forms collection so there is no real .NET version of that. Although it would be easy enough to do, just make your own forms collection. There are plenty of examples just search here or on google for 'Forms Collection'.
-
Jul 17th, 2003, 03:21 AM
#3
Addicted Member
I did it like this -
Created global variable
Public Forms As New cFormsCollectionClass()
Then in the New of each form added this
'Add to the forms collection
Forms.Add(Me)
And in the dispose added this
'Remove all from the forms collection
Forms.Remove(Me)
Then u always know what forms are about.
Wind and waves resolves all problems.
-
Jul 17th, 2003, 08:33 AM
#4
Thread Starter
^:^...ANGEL...^:^
Thanks for ur help. I think I am going to use this.
Application.Exit()
-
Oct 11th, 2003, 03:00 PM
#5
Fanatic Member
does Application.Exit() have the same effect as End? Because if it does, i dont want to use it.
But as its doing what I want it to for now, I wont remove it unless somone tells me its exactly the same as the End command in vb.
Thanks
-
Oct 12th, 2003, 12:27 AM
#6
there is some code posted in the vb.net codebank which i put there a while back showing how to unload all your Forms in .net, the basics of it are like this .....
VB Code:
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private Declare Function PostMessage Lib "user32.dll" Alias "PostMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim objType As Type() = Reflection.Assembly.GetExecutingAssembly.GetTypes()
Dim x As Integer, i As Integer
Try
For x = LBound(objType) To UBound(objType)
If Not objType(x).Name = Me.Name Then '/// make sure you dont unload this form yet.
i = FindWindow(vbNullString, objType(x).Name)
If Not i = 0 Then
PostMessage(i, CInt(&H10), vbNullString, vbNullString)
End If
End If
Next
Catch ex As Exception
MessageBox.Show("Oops, the following error occured:" & ex.Message)
Finally
MyBase.Close() '/// now that all the other forms are closed , unload this one.
End Try
End Sub
the link for the thread in the codebank is this...
Close all Forms in .Net
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Oct 12th, 2003, 07:56 AM
#7
Fanatic Member
-
Oct 12th, 2003, 08:45 AM
#8
Application.Exit() is basically the same as Ending an App with " End " ( which i recon is not good practice as it tends to terminate things abruptly )
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
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
|