If there is a thread related to this one please reply back the url, thx

What i have is Parent form that is the owner of multiple child forms, im having trouble trying to display the form, it flashes and then disappears


PrivateSub spawnNewChild(ByVal Name AsString, ByVal IP AsString, ByVal Mess AsString)

Dim ownedForm AsNew frmChild
With ownedForm
.Name = IP
.Text = Name
.txtReceived.AppendText(Mess + vbCrLf)


With ownedForm


Any help would be great, thx Jaeman

11 Years
Discussion Span
Last Post by jaeman

Hrm.. Looks like your bringing the other form ahead to early.. is that the entire code?

Lets start basic trouble shooting and put msgbox breaks in each line so we cna find out when she disappears.


msgbox "gothere"
msgbox "got here"

You follow?


Good to see im not the only one that uses mboxes for debugging, it should be the first recommendation made before someone posts a thread for the first time, Anyway...

Code has been changed but it should not affect it in anyway, it seems that the form disappears after the instantiation of the child form.

PrivateSub spawnNewChild(ByVal Name AsString, ByVal IP AsString, ByVal Mess AsString)

Dim ownedForm AsNew frmChild(IP,Name)

Me.AddOwnedForm(ownedForm) [No Problem - NP]

With ownedForm
.Show() - [NP]
.txtReceived.AppendText(Mess + vbCrLf) [NP]
.txtSend.Focus() [NP]


--- In Use - I put in a mBox and the form stays visible untill the messagebox is closed.

msgbox("Spawned") - [Still Visible]
Msgbox closed [Disappears]


Have you tried renaming this window to something else.. Can you paste full code.. soemthing is missing here..


This should be enough code to understand what i am doing.

When opening[spawning] a new child form the IP for that user is used as the forms Name, Then when a new message arrives it is send to the FindClient Sub to see if the form is open/active or not[and there is no problem with that], but if the form is not active the Sub the askes the user if they would like to accept the message, if they select Yes then the child form is opened/spawned, but you just get a flash of the form before it disappears, Note that once this happens you can't manualy open the form as it is already open, and i've tryed .Show .Visible = true etc etc to make the form visible.

' Open new chat window
Private Sub spawnNewChild(ByVal Name As String, ByVal IP As String, ByVal Mess As String)
Dim child As New frmChild(Name, IP)

With child
If Not Equals(Mess, "") Then
.txtReceived.AppendText(Mess + vbCrLf)
End If
End With
End Sub

' Find the Client and send message or ask to open new child
Private Sub findClient(ByVal FormName As String, ByVal Message As String)
Dim frm As frmChild
Dim blnFound As Boolean = False

For Each frm In Me.OwnedForms
With frm
' Look for the open form
If Equals(.Name, FormName) Then
.Controls(0).Text = Message ' Control(0) = childs message received box
blnFound = True
Exit Sub
End If
End With

If Not blnFound Then
' Split the name, date from the message
Dim inMSG() As String = Split(Message, " : ")
Dim User() As String = Split(inMSG(0), " : ")
' Ask to accept incoming message
Dim msg As String = _
"Do you want to accept a message from " _
+ inMSG(0) + " ..?"
Dim Result As DialogResult = _
MessageBox.Show(msg, "Incoming Message", _
MessageBoxButtons.YesNo, _
' Check the result
If Equals(Result, DialogResult.Yes) Then
' New Child
' Check if client is reachable
spawnNewChild(User(0), FormName, Message)
' Message is ignored
End If
End If
End Sub


This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.