homebrew311 Posted June 11, 2004 Posted June 11, 2004 Hey This has been very confusing to me and I can't think of any way to get this to work. I'm trying to make a simple instant messenging program as a summer project. For now I am working on the server part. I have the main form class (Form1) and a client handler class (ClientHandler). Once a user is connected, I want the client handler class to add the user name to a listbox on the main form called "lbUsers". In the beginning of this whole project, I thought that this would work: 'some code Dim MainForm as New Form1() MainForm.lbUsers.Add(Me.ClientID & " (" & UserName & ")") 'some code but after trying it out, the code didn't add anything to the listbox. Does anybody know how to add an entry to a listbox from another class? Quote
*Experts* mutant Posted June 11, 2004 *Experts* Posted June 11, 2004 Well, first of all you add something to the listbox using its Items property. Secondly, you are creating a new instance of the Form instead of referring to the one you already have. You are simply creating a new form and modifying it. Quote
homebrew311 Posted June 12, 2004 Author Posted June 12, 2004 Oh yeah sorry I forgot about the lbUsers.Items.Add thing in the post, but it's there in my code. I'll try not making a new instance. Thanks for your help. Quote
homebrew311 Posted June 12, 2004 Author Posted June 12, 2004 I took away the New in front of the Form1 and when the code executes I get an error saying "Object refrence not set to the instance of an object." Am I doing this all wrong? Sorry if this question is easy for you but I just don't know. Quote
Administrators PlausiblyDamp Posted June 12, 2004 Administrators Posted June 12, 2004 You may find this thread worth a read Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
homebrew311 Posted June 12, 2004 Author Posted June 12, 2004 Thanks a lot guys I got it to work. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.