Counting Newlines

H

Headley

I have a memo filed wher a user can enter text, including new lines (hard
returns). I want to be able to count how many times a new line/hard return
has been entered.

Does anyone out there in the land of know have any idea as to how I can do
this please. :)
 
D

Dirk Goldgar

Headley said:
I have a memo filed wher a user can enter text, including new lines
(hard returns). I want to be able to count how many times a new
line/hard return has been entered.

Does anyone out there in the land of know have any idea as to how I
can do this please. :)

This is a bit of overkill, but it's simple:

LineBreaks = UBound(Split([YourMemoField], vbCrLf))

or

LineCount = UBound(Split([YourMemoField], vbCrLf)) + 1

If the field may be Null, you have to allow for that:

LineCount = UBound(Split([YourMemoField] & "", vbCrLf))

An empty or Null field will then yield LneCount = 0.
 
H

Headly

You are a diamond geeza :))))

Now I can count those darstardly evasive newlines.

Thanks Dirk

Dirk Goldgar said:
Headley said:
I have a memo filed wher a user can enter text, including new lines
(hard returns). I want to be able to count how many times a new
line/hard return has been entered.

Does anyone out there in the land of know have any idea as to how I
can do this please. :)

This is a bit of overkill, but it's simple:

LineBreaks = UBound(Split([YourMemoField], vbCrLf))

or

LineCount = UBound(Split([YourMemoField], vbCrLf)) + 1

If the field may be Null, you have to allow for that:

LineCount = UBound(Split([YourMemoField] & "", vbCrLf))

An empty or Null field will then yield LneCount = 0.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
Top