Question Locked

MS Access - Count Lines in a text memo field

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I need to count the number of lines in a memo field that is 3" inches wide and set to 11 point text.

I am able to use VBA to count the number of hard returns, but I am unable to correctly count when the text auto wraps. Is there a character that I can look for?

4 replies

by tony hopkinson

is an internal decision of the 'memo' control itself. Essentially there's a best fit algorithm hidden deep inside it, and as far as it's concerned 300 chars followed by one hard return is one line.

As far as I know none of that is exposed through properties or methods, so you'd have to duplicate the logic, which would be problematic at best.

Why do you need to know, time for a bit of lateral thinking.

by jeffg

The memo field is classified ad copy that is billed per line. Column width ('memo' control width) along with font and point size may vary from newspaper to newspaper.

The system was to say x characters fit on a line. We are looking for better method.

by tony hopkinson

I don't think VBA has access to graphics at that level though.

For mono spaced fonts, you could write code to work it out, true type, though you are near boogered.

Then there's how accurate the screen representaion is to the newspaper one, and collating and maintaining the data about which paper uses which font. Never mind bold titles, mixed fonts/sizes, justification, lay out etc.

Perhaps this will help.

http://www.devsource.com/c/a/Languages/Text-Metrics-in-the-Net-Framework-Part-I/

PS , don't forget to take into account the screen resolution you are displaying the text you are measuring.

It's a well know git of problem though, anyone who guarantees that it will accurate to the line (+/- 1 line would be a good solution), is at best a congenital optimist.

This discussion is closed to new replies.