memo data type

ericlee

New member
Local time
Today, 20:53
Joined
Apr 6, 2005
Messages
5
hello there,

i have a field of memo data type in a table and the field is associated with a text control in a from. user is allowed to enter <ctrl><enter> to start on a new line in the control. if user exit this control, i would like to know how many lines are in this field. how can i do this?

thanks in advance.
 
The only thing I can think of is to loop through each character within the memo and count every instance of vbCr (enumerated constant for Carriage Return).

i.e.

Code:
Public Function CountLines(ByVal strMemo As String) As Long
    Dim lngCount As Long
    CountLines = 1
    For lngCount = 1 To Len(strMemo)
        If Mid$(strMemo, lngCount, 1) = vbCr Then
            CountLines = CountLines + 1
        End If
    Next lngCount
End Function
 
However, notice that with the above code, you will only get the number of vbcr which there are in your field ... for instance, if someone types something too long which automatically moves to the next line, those lines are still considered as 1.
 
maxmangion said:
However, notice that with the above code, you will only get the number of vbcr which there are in your field ... for instance, if someone types something too long which automatically moves to the next line, those lines are still considered as 1.

True. :D Hmmm...
 

Users who are viewing this thread

Back
Top Bottom