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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading a Multiline Textbox!

Status
Not open for further replies.

Paco75

Programmer
Oct 11, 2001
239
0
0
US
Hi,

Does anyone know how to read a multiline textbox... line by line in VBA?

thanks
 
I do not know how to do this but (and you may already have realized this) try recording a macro and perform the task you are trying to immitate. Then check out the code and tailor it to your needs. I'd try but I dont have anything that uses a text box. Good luck.
 
Unfortunately, that probably won't work. The macro isn't likely to record anything of value. If anyone has an answer to this one, I'd love to know. I've run into this myself - actually, my problem was with a word-wrapped cell, but the solution might be similar...
Rob
[flowerface]
 
For now I think It can be done if I take the .text property of the textbox and search for the end of lines characters... but I rather like to use something like a line position or an index...
 
There will be end of line characters only where the user purposely started a new line ("hard return", by hitting Enter or shift-Enter), not where the text wrapped around to the next line ("soft return"). Are you interested in finding only the hard returns, or both hard and soft?
Rob
[flowerface]
 
Hi!

I don't know what program you are using, but in Access a vbNewLine character is added to the string in a multiline text box. So all you need to do is:

strWork = MyTextBox.Value

strLine = Left(strWork, InStr(strWork, vbNewLine) - 1)
strWork = Mid(strWork, InStr(strWork, vbNewLine) + 2)

You can put this into a loop along with the code to do what you want with each line until you find no more vbNewLine characters.

hth
Jeff Bridgham
bridgham@purdue.edu
 
I'm looking to find the new lines entered by the user only. I must look for something like vbCrLf i guess?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top