473,414 Members | 1,665 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

VB code to count the number of lines in a memo Field on a form

I am trying to find some code that will count the number of lines in a memo field. Is there any such a thing?

Thanks, in advance.

Brian
Apr 16 '08 #1
5 2839
Stewart Ross
2,545 Expert Mod 2GB
Hi. There is no in-built function to do so, but it would be possible to write a custom function in VB.

What do you mean by lines, though? Is a line in your memo something that is ended by a certain defined punctuation mark? (question mark, period, exclamation mark)? Or do you just mean lines terminated by end-of-line markers (typically CR/LF combinations)?

Please advise

-Stewart

I am trying to find some code that will count the number of lines in a memo field. Is there any such a thing?
Apr 16 '08 #2
Thank you for replying. I call a line where it reaches the end of a field, and has to wrap around to the next line. I have users that just type notes in this field, and sometime don't even punctuate. Some notes are one line, some are several. What I'm trying to do so an if then statement concerning printing. for example, if the notes field is completely visible in the field, the it will not open the report with the notes, and print it. If the notes go beyond the height of the field, then it will open the notes report, and print. Let me know if you understand what I trying to do.

Thanks again,

Brian
Apr 16 '08 #3
Stewart Ross
2,545 Expert Mod 2GB
Hi Brian. I think I understand what you want to do - but it is simply not possible to count wrapped lines within the textbox.

I asked about what constitutes a line because without a clear definition a count has no meaning, and I'm sorry to say that the wrapping is of no help at all since wrapping is to do with internal character font sizes and widths, not the number of lines. In any event, text wrapping is an internal function of the textbox itself, not of any code which looks at the contents of the textbox.

I can't help you here - sorry.

You may wish to look at the 'can grow' property of a textbox on a report and set this to Yes. If the field is longer than can be fitted in the space available 'Can Grow' allows the field to extend vertically to fit the text.

-Stewart
Apr 16 '08 #4
missinglinq
3,532 Expert 2GB
The only possible approach to this, I think, would be to use a monospaced (fixed-width) font, such as OCR-B or Courier, count to find out how many characters comprise a "line" and then do something like

Lines = Len(Me.MemoField)/LineLength

Most people avoid monospaced fonts, because they're not very pleasing to the eye and are, for most people, difficult to read. If the "can grow" property (for reports) that Stewart mentioned looks like it might be of use to you, I believe Stephen Lebans has a hack on his site that provides the same functionality for forms.

Linq ;0)>
Apr 17 '08 #5
OK, thanks for looking into this. I'll try the options you suggest.

Thanks,

Brian
Apr 17 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Shyguy | last post by:
I want to create two buttons on a form. One would allow the user to Copy the contents of the current records memo field, the other would allow them to print. I set up a report based on the memo...
9
by: hope | last post by:
Hi Access 97 I'm lost on this code please can you help ================================= Below is some simple code that will concatenate a single field's value from multiple records into a...
2
by: Chris | last post by:
I'm sure this is a very easy one if you know, but any help would be appreciated I have a field in my database which needs to be as long as poosible. in the help it says that a memo field is 4000...
1
by: Daveyk0 | last post by:
Hello there, I have a front end database that I have recently made very many changes to to allow off-line use. I keep copies of the databases on my hard drive and link to them rather than the...
4
by: Bradley Burton | last post by:
I'm using Allen Brown's code for audit logging (http://allenbrowne.com/AppAudit.html), but I'm having a problem. My aud table doesn't populate with the tracking info at all. I think it might be a...
18
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on...
5
by: Dean | last post by:
Hi, I have a table with non-unique identifiers. I need to take all the values with the same ID's and combine them into one field with a semicolon as a seperator. These values may exceed 255...
2
by: bennylynch | last post by:
Hi, I am attempting to fill in 2 memo fields in the same form, which is fine, however the information on the second memo field is based on the information on the first one, so I need to hold the...
4
by: Bob Alston | last post by:
My client insists that the printed copy of text entered into a memo field have EXACTLY the same layout as it appears on the screen. I found I had to eliminate the vertical scroll bar. Then I...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.