Ask Experts Questions for FREE Help!
 

Free Answers in 3 Easy Steps

Register Now
3 Steps
 


Ask QuestionsprogressAnswer QuestionsprogressBuild ReputationprogressBecome an Expert
 
At Ask Me Help Desk you can ask questions in any topic and have them answered for free by our experts. To ask questions or participate in answering them you must register for a free account. By registering you will be able to:
  • Get free answers from experts in any of our 300+ topics.
  • Accept money for answers that you provide.
  • Communicate privately with other members (PM).
  • See fewer ads.
  Answer this Question    Ask about Visual Basic    Ask about another Subject  
 

albear
Apr 2, 2009, 11:29 AM
in visual studio 05 im using visual basic and on one form (form1) i have a listbox called Pnames and on a different form (form2) i have a textbox where the user inputs their name, on that same form i have a button that when clicked i want the name in the textbox to be added to the list box in form1

ive been looking for ways to solve this on the internet but when i tried it messed form2 up and i had to redo it again, any help would be greatly appreciated
thanks :)

Perito
Apr 2, 2009, 07:31 PM
Is the name of the listbox known before you compile? I presume it is, but if not, you'll have to use "reflection" to solve the problem.

If both forms have been created (you have instances to both forms), you can make the textbox Public on the Form1 listbox and access it directly from Form2. I don't like that approach, so I always create a Public Property on Form1. I then use that property from Form2 to pass the value that I want.

You'll have to pass a Form1 reference to Form2 when it is created. I suggest you use a Public Property to pass that reference also.

If you need examples, I can probably generate them for you.