Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing text to a text box

Status
Not open for further replies.

coxdon

Technical User
Mar 15, 2005
10
US
I have a little text substitution routine I wrote for MS Word and I'm trying to get it out of Word and into VB. To do that I need to figure out how to programatically write text, one character at a time, to a text box, or figure out a work around. Any ideas out there?
 




Hi,

"I have a little text substitution routine I wrote for MS Word ..."

What you wrote in MS Word is VBA. This forum is VBA.

Please post your code from Word and any code you have so far for your new procedure.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Thanks Skip. In MSWord I just created an array variable, (sSsource) and then I use the Type command and a loop to type in my text in a Textbox created in a MS Word form using VBA.

Do
Selection.TypeText Text:=sSource(y)
y = y + 1
Loop

What I'd like to do is take it out of MSWord (VBA) and put in in VB so that I can do this in a Text box on a VB form independent of MSWord. But I don't know the command (if there is one) in VB to enter data into a text box one character at a time, or how to write the data to a string and paste it into a Text box using the TextBox.Value statement.
 



"enter data into a text box one character at a time"

The short answer is
Code:
Textbox1.Text = Textbox1.Text & YourCharacter
What is the purpose for this? The code you posted does NOT do what you clain that it does. A TextBox is for a user input. Why are you attempting to "type" characters in a loop?

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Skip
It's pretty simple actually. I want to build a form with 2 text boxes. The user types "TEST" into the first text box, clicks on a command button, and the text is replaced with "&8*^" (or whatever) in the second box. It's a simple text substitution for privacy purposes, useful for email, etc. Kind of like a translation form that you frequently see on translation web sites. It works find in MSWord using the .count and .type commands to read text into and out of an array variable. Thanks for the suggestion.
 



Why not use the PasswordChar property of the Control Toolbox TextBox object?

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top