Click to See Complete Forum and Search --> : print field memo in lines
Marcelo Velasquez
Jan 9th, 2000, 06:48 PM
Hi
I have a field memo in a table of ACCESS and do I need to print this field in lines of at the most 67 characters, As I make this without breaking words?, does some ready function Exist?
------------------
The blessing of God enriches and it doesn't increase pains
MartinLiss
Jan 10th, 2000, 11:59 AM
If you have VB6 you can do the following. If you have VB5 then you'll need to use InStr and modify the routine to go forward through the string rather than backward as I have done. Dim sMyString As String
Dim nPos As Integer
Dim nStartPos As Integer
Dim bDone As Boolean
sMyString = MySnapshot!MyField
nStartPos = Len(sMyString) - 1
nPos = nStartPos
Do Until bDone
If Len(sMyString) <= 67 Then
Debug.Print sMyString
bDone = True
Exit Do
End If
Do Until nPos <= 67
nPos = InStrRev(sMyString, " ", nStartPos)
nStartPos = nStartPos - 1
Loop
Debug.Print Left(sMyString, nPos - 1)
sMyString = Right(sMyString, Len(sMyString) - (nPos)) 'ok
nStartPos = Len(sMyString) - 1
nPos = nStartPos
Loop
------------------
Marty
Marcelo Velasquez
Jan 10th, 2000, 08:15 PM
What is InStrRev ?
------------------
The blessing of God enriches and it doesn't increase pains
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.