-
I need to get the context of a textbox, placed on a special form into a string variable which I can use in another form.
I need this because I want the user of my app to write some text in a textbox on a popup-form and press a Commandbutton which will close the popup-form, retun to the standard from and there use the context of the textbox in a function.
I can't use the inputbox function, since I need the textbox to use Password chars (or is it a function to get the inputbox to do that?).
I've tried something like Form1.strText = Form2.Text1.Text, but it doesn't work.
So, how can I use variables in different forms?
Hope you can help me,
thanks,
Pentax
-
I would think that this should work when placed in form1
dim strText as string
strtext=form2.text1.text
-
The standard inputbox does not allow for password characters. If you want to read the text that the user types into your popup form there are several things you can do. If you Hide your popup form rather than unloading it after the user presses the command button, you can easily refer in the standard form to what the user typed in the popup form with code like MsgBox frmPopup.Text1.Text. If you'd rather unload the popup form, add a code module to your application (if you don't already have one) and in the Declarations section add something like Private g_strUserInput As String, then in the click event of the command button add g_strUserInput = Text1.Text. Then when you want to use the value in your standard form code MsgBox g_strUserInput.
-
Thnanks, I'll try that.
Another thing is, I've got a (rich)textbox covering my entire form (sized 10000x10000). How can I get it to follow the form if the size is changed? It's for a text editor, so I want the window to be as large as the form, but with place for scrollbars.
As it is now, it is big engouh when starting up, but if I resize the from, the textbox stays the same size.
Pentax
-
You can change the size of the text box inside of the form_resize event:
text1.width = form1.width
text1.height = form1.height
-
Use the ScaleWidth and ScaleHeight properties of the form instead of the Width and Height properties.
Code:
Private Sub Form_Resize()
Text1.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight
End Sub
Good luck!
PS.
Hur är det i Kungsbacka så här års?
-
Thanks
Thanks, I'll try.
Now, the problem is to get the RichTextBox to break lines when I resiz the window.
Sigh, I'm never out of problems...
Pentax
PS.
Här har våren kommit, med tillfälliga bakslag då och då.
Var någon stans väntar du på värmen?
-
Just set the RightMarfin property to 0 (zero). If you need any more information about how to extend a TextBox or a RichTextbox try reading my article at:
http://www.vb-world.net/api/textboxex/
Good luck!
PS. I Södertälje är vi i väntans tider... DS.