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

How to format Lines of text..

Status
Not open for further replies.

vbSun

Programmer
Dec 9, 2002
504
US
Hi,

I would like to ask help doing this. I have some unformatted text. I need to make it fixed length each line, insert newlines at end of each line, without breaking the words, and keeping current carriage returns intact. I dont know how to use Regular Expressions, but will it help?

Pls help me to get a solution.

Thanks
Sunil
 
Hi

it could be like:
[tt]
v_Words = split(s_UnformattedText," ")

For i=0 to ubound(v_Words)
if i_WordsInLine = C_WORDS4Line then
s_Line = s_Line & v_Words(i) & vbcrlf
s_FormattedText = s_FormattedText & s_Line
s_Line = ""
i_WordsInLine = 0
else
s_Line = s_Line & v_Words(i)
i_WordsInLine = i_WordsInLine + 1
End if
Next

txt_FormatedText.Text = s_FormattedText
[/tt]

Well. What do you think?
 
hmm..

It has to be a little more complex than this. I think you are formatting the words per line, but i need the line length to be fixed, all the time.. all the chars.. including spaces.. with out breaking words.. Is it possible?

Well it is possible, but i was not able to perfect the logic yet..Thanks for the response..

Sunil
 
Just how complex do you want it? For example, is the line-breaking that you see in a textbox sufficient?
 
Ok - do you want sophisticated hypenation and kerning algorithms? Are you working with fixed fonts or proportional fonts? Are there likely to be be changes in font size or style in the line?

Or do you just want to break a single-format plain text line at the last white space prior to reaching the theoretical line end (like VB does in a multiline textbox)?
 
This is probably a stupid question...No changes there then...

Sunil,

I've seen your other threads and they all seem to be related. I think the problem may be simply that you haven't set the textbox's MultiLine property to True, so your text is "disappearing off the end" instead of wrapping nicely. I know you're banging your head on this one, but can you go right back to basics - What exactly are you trying to do, and what exactly is the problem? Screen not displaying properly? Printing problem? Need to store the data in a fixed-length field?

I have a feeling we're all getting the wrong end of the stick, here...
 
Thanks comaboy for the response,

I am sorry if i put it in the wrong way.. It was not the multiline that i needed.. even though am only 25, i have been programming for food for 5 years now.

Strongm resolved my issue.. and its definitely good to know there are many things that we dont know..

Thanks once again,
Sunil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top