How can I only allow 35 charachters per line in a text box? I am making a program for the user to enter data and then hit a button to copy that data and will be pasted into a program called Seagull and it only allows 40 characters per line and it does not wrap. I have to hit enter or tab twice to go to the next line
what about something like this i found? I am not exactly sure what it means but i guess it is supposed to work
orCode:Function FormatByLength(Expression As String, Length As Long) _ As String Dim BufferCrLf() As String Dim BufferSpace() As String Dim Buffer As String Dim k As Long Dim j As Long Dim count As Long On Error GoTo FormatByLengthError BufferCrLf() = Split(Expression, vbCrLf) For k = 0 To UBound(BufferCrLf()) If Len(BufferCrLf(k)) <= Length Then Buffer = Buffer & BufferCrLf(k) & vbCrLf Else BufferSpace() = Split(BufferCrLf(k), " ") For j = 0 To UBound(BufferSpace()) count = count + Len(BufferSpace(j)) + 1 If (count <= Length) Then Buffer = Buffer & BufferSpace(j) & " " Else count = 0 Buffer = Buffer & vbCrLf & BufferSpace(j) & " " count = Len(BufferSpace(j)) + 1 End If Next j Buffer = Buffer & vbCrLf End If Next k FormatByLength = Buffer Exit Function FormatByLengthError: End Function
Code:textbox2.Text = FormatByLength(textbox2.Text, 72)




Reply With Quote