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

Wrap Text in RichTextBox 1

Status
Not open for further replies.

victoryhighway2

Programmer
Jul 18, 2005
42
US
Hello All,
I've been searching the 'net for quite a while looking for a way to use the RichTextBox control (or some equivalent) to simulate a text display of one of our products in a Visual Basic 6.0 application. The only problem that I've run into so far is that the RichTextBox will perform word-wrapping of the lines, but our product line wraps by character only.

For Example:
Jack An
d Jill W
ent Down
the Hill.

Does anyone know how to do this with the RichTextBox, or is there an alternative that will allow this?

Regards,
Geoffrey
 
On what criteria does it wrap the characters?

Cheers

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Most simple way to do this is to convert all spaces with non-breaking spaces. Non-breaking spaces behave like ordinary characters and Windows does not perform word-wrapping with these characters.

In this way, as there is no space in your message, Windows automatically performs character-wrapping instead of word-wrapping.

Place a RichTextBox control on your form and test the following code.
___
[tt]
Option Explicit

Private Sub Form_Load()
'initialize RTB
With RichTextBox1
.Move 0, 0, 1890, 3000
.Font = "Times New Roman"
.Font.Size = 24
End With

Dim S As String
S = "Jack And Jill Went Down the Hill."
'replace spaces with non-breaking spaces
S = Replace$(S, Chr$(32), Chr$(160))

'assign to RTB
RichTextBox1.Text = S
End Sub[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top