' Collection of code snippets by Arne Vajhøj 
' (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
Private Sub Command1_Click()
    Dim s() As String
    Dim ix1 As Integer
    Dim ix2 As Integer
    Dim i As Integer
    s = Split(Text1.Text, " ")
    ix1 = 0
    ix2 = 1
    While ix2 <= UBound(s)
        If Len(s(ix1)) + Len(s(ix2)) < CInt(Text2.Text) Then
            s(ix1) = s(ix1) & " " & s(ix2)
        Else
            ix1 = ix1 + 1
            s(ix1) = s(ix2)
        End If
        ix2 = ix2 + 1
    Wend
    ReDim Preserve s(ix1)
    Text3.Text = ""
    For i = 0 To UBound(s)
        Text3.Text = Text3.Text & s(i) & vbCrLf
    Next
End Sub
