View Full Version : Solved: copy value from one textbox to another.
Birch81
07-29-2010, 04:33 AM
Hey,
I want to know if there is anyone who can help me moving som text from one textbox to another.
I we say I have to textboxes and when i write in textbox 1 the value is also written in textbox 2. is this possible?
/Birch81
Tinbendr
07-29-2010, 05:10 AM
What kind of textbox?
From Control Toolbox? Or Userform
Me.TextBox2 = Me.TextBox1.Text
When? After exit or as you change Textbox1
Private Sub TextBox1_Change()
or
Private Sub TextBox1_Exit()
Or a graphic textbox
ActiveDocument.Shapes(2).TextFrame.TextRange.Text = _
ActiveDocument.Shapes(1).TextFrame.TextRange.Text
So many questions linger....
Birch81
07-29-2010, 06:09 AM
yeah okay sorry.
iItīs a userform where I have many textboxes and I need to use the value from one of them and manipulate with the value and then copy it to the other textbox.
fumei
07-29-2010, 09:34 AM
You just make the .Text of one equal the .Text of the other.
Textbox2.Text = Textbox1.Text
Note that if you use the _Change event every single change fires the code.[vba]
Sub Textbox1_Change()
Textbox2.Text = Textbox1.Text
End Sub[vba]That means if you type "yadda" in Textbox1:
- type "y"
- Textbox1_Change fires
- type "a"
- Textbox1_Change fires
- type "d"
- Textbox1_Change fires
- type "d"
- Textbox1_Change fires
- type "a"
- Textbox1_Change fires
You may want to try other events such as _Enter (for the next control), or maybe _AfterUpdate. I would also like to point out that if the second control is taking a value from the first...it may be better to NOT have it as a textbox. Textboxes are for user input. If the text content is NOT going to be changed by the user, then use a Label instead.
Birch81
07-29-2010, 11:16 PM
Hey,
Thank you very much for your help. The problemis now solved :bow:
I used the change function which is perferct for this project.
Again thank you.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.