-
November 25th, 2008, 05:19 AM
#1
[RESOLVED] Setting object(Form) to nothing from within the object
Well during testing the project came up with an interesting bug, If we close the form object (and dispose of it), it's object has not been set to Nothing, and now still responds to events..
Creating the Form ....
Code:
Private WithEvents FormVending As FrmVending
Private Sub MenuItemOnClick_Vend_CredRef(ByVal sender As Object, ByVal e As EventArgs)
FormVending = New FrmVending(thisUserID, thisUserName)
FormVending.MdiParent = Me
FormVending.Show()
End Sub
When the form is loaded it must get data from the comms object, everytime a token is inserted.. Like this..
Code:
Private Sub Comms_Mode_Token_In() Handles Comms_Mode.Token_In
ToolStripReaderStatus.Text = "[Token IN]"
If Not FormVending Is Nothing Then
FormVending.TokenData = Comms_Mode.TokenData
End If
End Sub
However when the form is closed, it is still replying to the above code.. even though i am disposing of it..
Code:
Private Sub FrmVending_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
Me.DestroyHandle()
Me.Dispose(True)
End Sub
The thing is, I probably can simply add an event to the form so that the main class will set the object reference to Nothing. But i'm looking for a solution where i can set the object to nothing from with in the object, as i may have to add this to several other forms (many of which currently have not been setup for events..) ..
Thanks
Gremmy...
Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
WPF Articles : 3D Animation 1 , 2 , 3
Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.
Tags for this Thread
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
|