Weird Text Box Behaviour

bonedoc

Well-known member
Joined
May 4, 2006
Messages
112
Programming Experience
Beginner
I am about to go crazy. I cant figure this out. I have 3 forms. When working in form 3, I can set the textbox1.text of form 1 by:

form1.textbox1.text = "test"

But, if I try the same thing with form 2:

form2.textbox1.text = "Test Again"

Nothing changes. The code runs fine. No errors, but the text does not change. What is even more crazy, if I do:

messagebox.show(form2.textbox1.text)

The messagebox shows what I wanted to appear there...but it is not there. Does anyone have any ideas why this would happen? I have done this tons of times, but have never seen this. Thanks
 
If Messagebox.Show(Form2.Textbox1.Text) shows the text, then its there.

If its not showing on the screen, try adding a Form2.Refresh after you set the textbox value on Form2. This will force the application to repoll Form2 to the screen.

See if that makes a difference.
 
that is not working either. It is very strange. Actually, it wont even take the form2.close command.....crazy
 
Last edited:
I agree with Raven65, if the messagebox didn't show anything, then is nothing there. We need more information on how you do the code. The sequence of code, will affect the logic. For example, if you put code in your form2.shown event to initialise all the textbox, then whatever you had set to form2.textbox will disappear.
 
Well, all of the form2's contruction was done by the form generator. However, I am adding text to te textbox on the forms2.load event.....and then the form2.textbox1.text = "..." does not work. Could adding text during the form2.load event affect this?

Actually, I take that messagebox thing back. It will not display it now. In fact, I cant make a single refernce to form2. It is like it is there, but the events are not being passed to the controls. You know, I did change the name of the form at one point. Is it possible that this caused something to go wrong in the reference of the form?
 
Last edited:
How do you bring up the form2? There are few ways to bring up the form
1) Dim FrmToShow as new Form2
FrmToShow
This will instantiate a new form, and will fire the form's load event

2) form2.show() and you call me.hide() in one of the form2 event. The form2 will be re-use and form load event only fire only for the first time loaded.

3) Check is there any places that you initialise form2.textbox1.text?
 
How do you bring up the form2? There are few ways to bring up the form
1) Dim FrmToShow as new Form2
FrmToShow
This will instantiate a new form, and will fire the form's load event

2) form2.show() and you call me.hide() in one of the form2 event. The form2 will be re-use and form load event only fire only for the first time loaded.

3) Check is there any places that you initialise form2.textbox1.text?

I use dim x as new form2
x.showdialog(me)
 

Latest posts

Back
Top