Below is a routine which accepts two parameters, a string, and the text box in which to display that string. It relies on the underlying assumption that the font settings for the form are the same as those of the text box. If you need to change the form settings, be sure to set them back. Since Multiline is a read-only property, be sure to set it to true at design time.
One other note - if this string is going back into a database, then I would suggest that you replace the vbCrLf with a space using the Replace function before writing back to the DB.
TheString = Replace(txtTextbox.Text, vbCrlf, " "
'=============================================================
Private Sub LoadTextBox(rStr_TheString As String, txtTheTextBox As TextBox)
Dim lStr_ThisLine As String
Dim lStr_FullLine As String
Dim lStr_Words() As String
Dim lInt_Idx As Integer
Dim lInt_MaxWidth As Integer
Dim lStr_ThisWord As String
lInt_MaxWidth = txtProject.Width - 30
' All for a Margin
lStr_Words = Split(rStr_TheString, " "
' Break into Words
lStr_FullLine = lStr_Words(0)
' Assign First Word
lStr_ThisLine = lStr_Words(0)
' Assign First Word
For lInt_Idx = 1 To UBound(lStr_Words)
' For the Rest of the Words
lStr_ThisWord = " " & lStr_Words(lInt_Idx)
' Add the separating space
If (Me.TextWidth(lStr_ThisLine & lStr_ThisWord) < lInt_MaxWidth) Then
' Will it Fit?
lStr_ThisLine = lStr_ThisLine & lStr_ThisWord
' Add to this line
lStr_FullLine = lStr_FullLine & lStr_ThisWord
' Add to full string
Else
lStr_FullLine = lStr_FullLine & vbCrLf & lStr_Words(lInt_Idx)
' Add CRLF and Word
lStr_ThisLine = lStr_Words(lInt_Idx)
' Start New Line with just this word
End If
Next lInt_Idx
txtTheTextBox.Text = lStr_FullLine
' Assign to text box
End Sub
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein