Reputation: 195
I have a form that can spawn a child form, something like:
Private Sub RunBtn_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles RunBtn.Click
Dim myChildForm As New form2()
myChildForm.Show()
End Sub
I want to be able to launch multiple children. Unfortunately, I seem to be getting conflicts within the controls of the children. One button will run the other child's control, etc. They also seem to think that their class-level variables are accessible to each other. Private Shared variables like the following are conflicting (one form thinks it's seeing the other form's "mp3file" variable as their own):
Public Class form2
Private Shared mp3file As MemoryStream
....
End Class
How do I spawn children forms that keep their controls and data separate?
Upvotes: 1
Views: 240
Reputation: 3156
Using Private Shared is shared across all instances of that class
Private Shared mp3file As MemoryStream
Simply remove the Shared attribute
Upvotes: 1