sorry for the poor communication.
1. I need to find the space at or before 80
2. I'm trying to make the code to accept the memo field text and return the
second section as a string or query field. i.e. query
field=funSplitText([memo field], lines to break at)
3. returned string would be the beginning of the 14th line to the end of the
input string.
the code i have so far, which has problems:
Public Function funSplitTxt2(strTxt As String, intBreakLine As Integer) As
String
Dim astrLF() As String
Dim astrWords() As String
Dim strTmp, strText As String
Dim intUbLf, i, intLines As Integer
Dim aLines() As Variant
astrLF() = Split(strTxt, vbLf)
intUbLf = UBound(astrLF())
MsgBox LBound(astrLF()) & vbLf & intUbLf
ReDim aLines(intUbLf + 1)
intLines = 0
For i = 0 To intUbLf
Dim astrLines() As String
If Len(astrLF(i)) > 80 Then
Dim intUbW, intI, intL, intLen As Integer
astrWords() = Split(astrLF(i))
intUbW = UBound(astrWords())
intI = 0
intL = 0
strTmp = ""
Do Until intI = intUbW + 1
intLen = Len(strTmp) + Len(astrWords(intI)) + 1
Select Case intLen
Case Is < 80
strTmp = strTmp & " " & astrWords(intI)
intI = intI + 1
Case 80
strTmp = strTmp & " " & astrWords(intI)
ReDim Preserve astrLines(intL + 1)
astrLines(intL) = Trim(strTmp)
MsgBox "@" & Trim(strTmp) & "@"
strTmp = ""
intL = intL + 1
intI = intI + 1
intLines = intLines + 1
Case Is > 80
ReDim Preserve astrLines(intL + 1)
astrLines(intL) = Trim(strTmp)
MsgBox "@" & Trim(strTmp) & "@"
strTmp = ""
intL = intL + 1
intLines = intLines + 1
End Select
Loop
If Len(strTmp) > 0 Then
ReDim Preserve astrLines(intL + 1)
astrLines(intL) = Trim(strTmp)
intLines = intLines + 1
MsgBox "@" & Trim(strTmp) & "@"
End If
Else
MsgBox CStr(Asc(Right$(astrLF(i), 1)))
astrLines(0) = Replace(astrLF(i), vbCr, "")
intLines = intLines + 1
MsgBox "@" & Trim(astrLF(i)) & "@"
End If
aLines(i) = astrLines()
Next i
strTmp = ""
Dim astrLF2() As String
ReDim astrLF2(intUbLf + 1)
For i = 0 To intUbLf
Dim astrLines2() As String
astrLines2() = aLines(i)
strTmp = Join(astrLines2())
astrLF2(i) = strTmp
strTmp = ""
Next i
strText = Join(astrLF2(), vbNewLine)
'strText = Join(astrLF(), vbLf)
MsgBox "Lines: " & intLines
funSplitTxt2 = strText
End Function
I am not the best programer. I'm an entirly self taught amatur.