B2Ben
Well-known member
- Joined
- Aug 17, 2006
- Messages
- 52
- Programming Experience
- Beginner
OK... so I want to add some data to a listbox on my Form1. I can do it successfully using a button on my form (See Button1 below). However, when one of my objects (NetServer) raises an event, my Form1 handles that event, starts executing some code, but it cannot modify my listbox and I don't know why.
Below is some code from my form, with comments explaining what works and what doesn't. If you'd like to see more code or more information, let me know... this is driving me up the wall here...
Below is some code from my form, with comments explaining what works and what doesn't. If you'd like to see more code or more information, let me know... this is driving me up the wall here...

VB.NET:
Public Class Form1
Friend WithEvents NetServer As New NetServer(22000) 'Initialize NetServer
Private Sub Client_Connect(ByVal IPAddress As String) Handles NetServer.ClientConnected
Beep() 'NOTE: This works properly after the event is received
Me.listbox_clients.Items.Add(IPAddress) 'NOTE: This doesn't happen... Why??
MsgBox("Form1 Received Client Connected: " & IPAddress) 'NOTE: This doesn't happen... Why??
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.listbox_clients.Items.Add("Test") 'NOTE: This works properly after clicking Button1 on Form1
End Sub