Counting Lines of Text in TextBox

In a form, I have a text box in which memo text wraps.  Is there any code 
that can count the number of lines of text that display in the textbox?

My only workaround at this point is to use a non-proportional font like 
Courier, count the characters and divide by the number of characters that a 
line might contain.  Unfortunately, this approach only gives me a rough 
estimate of the number of lines.  And I'm stuck with Courier when I prefer 
Arial.

Is there another way to count lines of text?

Thanks.

Jim
0
Utf
2/25/2010 6:44:02 PM
access.formscoding 7493 articles. 0 followers. Follow

3 Replies
1260 Views

Similar Articles

[PageSpeed] 16

Why?

What will knowing the number of lines of text allow you to do?

Regards

Jeff Boyce
Microsoft Access MVP

-- 
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

"JBA" <JBA@discussions.microsoft.com> wrote in message 
news:DEBE6915-5192-463C-8A27-7C1715C049A5@microsoft.com...
> In a form, I have a text box in which memo text wraps.  Is there any code
> that can count the number of lines of text that display in the textbox?
>
> My only workaround at this point is to use a non-proportional font like
> Courier, count the characters and divide by the number of characters that 
> a
> line might contain.  Unfortunately, this approach only gives me a rough
> estimate of the number of lines.  And I'm stuck with Courier when I prefer
> Arial.
>
> Is there another way to count lines of text?
>
> Thanks.
>
> Jim 


0
Jeff
2/25/2010 7:28:34 PM
JBA wrote:

>In a form, I have a text box in which memo text wraps.  Is there any code 
>that can count the number of lines of text that display in the textbox?
>
>My only workaround at this point is to use a non-proportional font like 
>Courier, count the characters and divide by the number of characters that a 
>line might contain.  Unfortunately, this approach only gives me a rough 
>estimate of the number of lines.  And I'm stuck with Courier when I prefer 
>Arial.
>
>Is there another way to count lines of text?


The TextHeight function at
http://www.lebans.com/textwidth-height.htm
can be used to do that.

-- 
Marsh
MVP [MS Access]
0
Marshall
2/25/2010 7:30:46 PM
Thank you Marshall.  The TextHeight function looks like a good solution.

Jim

"Marshall Barton" wrote:

> JBA wrote:
> 
> >In a form, I have a text box in which memo text wraps.  Is there any code 
> >that can count the number of lines of text that display in the textbox?
> >
> >My only workaround at this point is to use a non-proportional font like 
> >Courier, count the characters and divide by the number of characters that a 
> >line might contain.  Unfortunately, this approach only gives me a rough 
> >estimate of the number of lines.  And I'm stuck with Courier when I prefer 
> >Arial.
> >
> >Is there another way to count lines of text?
> 
> 
> The TextHeight function at
> http://www.lebans.com/textwidth-height.htm
> can be used to do that.
> 
> -- 
> Marsh
> MVP [MS Access]
> .
> 
0
Utf
2/25/2010 9:59:01 PM
Reply:

Similar Artilces:

Loading PivotCache directly from a text file
According to the Excel online help, the PivotCache.Connection property can be set to "the path to and file name of a text file". I tried setting it to the path and file name of a .csv file and it returned an error. Is there a way to load a PivotCache directly from a flat file without having to load into a spreadsheet or database? (The flat file has more than 1 million rows.) -- Tom Sherwood ...

Displaying Counts when Filtering
Usually when using the filter function, the total records in the spreadsheet and the number of records that match the filter criteria are displayed on the lower left of the window (I guess it's the status bar). However, for certain files that I have, no counts are displayed when I filter. Does anyone know if there is a setting in the file that causes this or something else that needs to be changed? I do notice this happens frequently with files created by exporting from Access, but not always. It also happens with other files, but I can't find a common denominator. Hi To...

Display text in Excel Bubble chart. #2
H1!, I have an Excel spreadsheet which contains X-coordinates, Y-Cordinates, Well name and Cumulative Oil/Gas/Water production. I have created bubble map using X,Y and Z(Cum production). I need to show the well name on each Bubble, which I am unable to do. Kindly sugest method to display the well name on the bubbles. Thanks, Raja Mukherjee Raja - Rob Bovey's Chart Labeler (http://appspro.com) is a free addin that adds text from the worksheet to data labels on a chart series. I just tested it on a bubble chart and it works fine. - Jon ------- Jon Peltier, Microsoft Excel MVP ...

Creating a chart with text not numbers
How do I create a chart that has text values (freshman, sophomore, junior, senior) instead of numbers (1, 2, 3, 4)? I have a column labeled "What is your class standing?" and below it is 166 rows where people selected "Freshman," "Sophomore," etc. I want to create a bar chart that counts how many people selected each of the four classes. Thanks, Alan First of all, you will have numbers to plot. The words are your category labels. Read how to turn a column of words like this into a histogram: http://peltiertech.com/Excel/Charts/Histograms.html - Jon...

Validate almost one of two textbox
Hi, how can I validate a group of 2 textbox so the users have to populate at least one of them (or both)? Thanks in advance. Luis On Nov 27, 2:16=A0pm, Luigi <Lu...@discussions.microsoft.com> wrote: > Hi, > how can I validate a group of 2 textbox so the users have to populate at > least one of them (or both)? > > Thanks in advance. > > Luis Use Javascript Function function jsValidateTextBoxGroup(sTxtBox1, sTxtBox2) { var bSuccess =3D true; var sTxtBox1Value =3D document.getElementById(sTxtBox1).value; var sTxtBox2Value =3D document.g...

Extend text to next cell
I am trying to get my text to run over to the next cell only in display not actual value of that cell. So if A1 says, "How now brown cow.", it should show over cells A2 and A3. However, I also need the carriage returns to be picked up. If I use the "Wrap Text" property it only shows the sentence in that cell. If I don't use it I get the [] (brackets) in place of the carriage return. Maybe you could merge those cells (A1:A3 or did you really mean A1:C1?) But be aware that merging cells causes trouble with sorting, pasting, and lots of other stuff. Format|cells|al...

How to Populate .msg File Used in Command Line
I have a .msg file I saved as a boilerplate for Calendar requests that will be programmatically started in an application I am developing. I want to be able to modify the Calendar request's date, time, duration, and message contents based on the user's inputs prior to opening the .msg file. After the user verifies the contents, he/she will click the <Send> button. Currently, from the command line, I can run "c:\program files\microsoft office\office12\outlook.exe" /f "c:\p_review\PR.msg" The Calendar request opens with the boilerplate. Ho...

Count of Unique Items?
Hi, I have a worksheet (Sheet1) where column A consists of dates (in date order). I need to look at this column from another sheet (Sheet2) in the same workbook and return the number of unique dates in this column. For example, on Sheet1 cell A1 has the heading Date, A2 is 10/01/04, A3 is 10/01/04, A4 is 10/01/04 and A5 is 10/05/04. From cell A1 on Sheet2 I need to look at the range A2:A5 on Sheet1 and return the number 2 (the number of unique dates in the range). Any help would be greatly appreciated. Monte Sliger Try the following... =SUM(IF(Sheet1!A2:A5<>"",1/COUN...

Justifying text of an axis
How do you justify the text of an axis in an excel chart? On Mon, 21 Apr 2008, in microsoft.public.excel.charting, mdicke <mdicke@discussions.microsoft.com> said: >How do you justify the text of an axis in an excel chart? You can't, it's fixed by the axis. The best you can do is select a monospaced font and use a custom number format with ???? (question marks). -- Del Cotter NB Personal replies to this post will send email to del@branta.demon.co.uk, which goes to a spam folder-- please send your email to del3 instead. ...

Need RULE to search for Text in Body with varying # of spaces
Hi there, I have Outlook 2002 and have been using the outlook rule condition: "With specific words in the body" However the "Specific words" I'm looking for might contain varying number of spaces: EX: "some text: some more text" "some text: some more text" Is there a wildcard or something to match multiple spaces? --Thanks very much, Kenneth Kenneth Parker <kenneth.parker@sas.com> wrote: > I have Outlook 2002 and have been using the outlook rule condition: > "With specific words in the body" > > However...

One line is killing my program!
The following line works, where it specifies the first 4 characters of two area codes (403, and (587. .Range("C2:C" & q).FormulaR1C1 = _ "=MID(R[0]C[-2],INDEX(FIND({""(403"",""(587""},R[0]C[-2]),MATCH(TRUE,ISNUMBER(FIND({""(403"",""(587""},R[0]C[-2])),0)),14)" I need to substitute two variables - areaCode1 and areaCode2 to replace (403 and (587. I think I've done so, but the following doesn't work: .Range("C2:C" & q).FormulaR1C1 ...

2 existing spreadsheets show 1st line rather than header row to sort ...
(XL2003) This is odd, I haven't seen this ever before. I was working on spreadsheets yesterday for a mail merge. Two had headers rows. I cleaned up both documents, put print area and then tried to sort. In both cases, what came up in the sort was the first row below the header where one always sees the actual titles of the header row when one selects the Header Row radio button under "My List Has" in the "Sort" box. I fiddled and fiddled a bit and managed to get one of the workbooks to display the sort properly by the header row titles - without figuring out what ...

text font color won't print in Excel, why?
I am using Excel 2002. I changed the text font color of the cell. It displays correctly on my screen, but it prints as black text even though I selected a pale yellow. Word 2002 prints correctly. The pale yellow prints as a light shade of gray. Does anyone know why? Thanks eagle Perhaps in Page Setup>Sheet you have "Black and White" checked? Gord Dibben Excel MVP On Sun, 23 Jan 2005 22:51:01 -0800, eagle7 <eagle7@discussions.microsoft.com> wrote: >I am using Excel 2002. I changed the text font color of the cell. It >displays correctly on my screen, b...

Imported text file w/o unique identifiers, find duplicates
Imported a txt file w/o unique identifiers and have run a query to find possible duplicate records based on 3 seperate fields. How can I either update those fields that may be in error in the original table or append a new record w/o the duplicate data and delete the original record? In the following I need to determine which records to keep, which to delete and/or which to update. End Date Total Sheets Time Operator Name 3/3/2007 14 0:00 00094123 B D MCNARA 3/3/2007 14 0:00 00095681 NAME UNKNOWN 3/17/2007 84 0:01 00091234 C D S 3/17/2007 84 0:01 000...

counting seconds
=SECOND(NOW()) and holding down the F9 key starts at whatever the second hand is pointing at and counts up to 59, then starts back at 0, 1, 2, to 59, 0, 1, 2 and so on. How can I write it so it starts at 0, and counts 1, 2, 3,...,59, 60,61,...forever? Hi have a look at http://www.mvps.org/dmcritchie/excel/datetime.htm (at the bottom of this site): There are some example counters / stop timer functions. This may what you're looking for -- Regards Frank Kabel Frankfurt, Germany "scott" <anonymous@discussions.microsoft.com> schrieb im Newsbeitrag news:143e601c3f7f9$b63ac...

Count with two criteria
I am working in Excel 2003, I am trying to count with two criteria and multiple sheets. I am using this formula: =SUMPRODUCT(('Sum 1Q10'!A2:A4="BKD")*('Sum 1Q10'!F2:F4="Open")) my result is 0. It should be 1. Is there another way to do this? I really need help. Lisak- There are a couple of approaches to do this; I'll give you the one I use out of habit. The sumproduct conditions evaluate to true or false. You have to force them back to a numeric format. Some folks do that with a leading double negative on each condition. I tend to ...

Importing text files into Excel
Does anyone know of a quick and easy way to bring large text files into Excel. The data in the text files is separated by spaces. The spaces that separate the data vary in number. I have tried to replace the spaces with tabs while in Notepad but it takes too long. Any help would be appreciated! Thanks Chris Open Excel and create a blank workbook. Then: Data | Get External Data | Import Data (this command might be something like Import Text File, if you are using an older version of Excel). Browse to find your file and click to Import it. Should open up the Text Import Wizard. Make...

What can stop a PC from displaying Access 2000/2003 text & background colours?
Can anyone suggest a reason why a specific Dell Inspiron 9300 laptop should be unable to display any of the text or background colours on an utterly basic test form with only a couple of text boxes and no VBA code on an otherwise empty test database? The problem also happens with an application of mine using Access 2003 runtime - but only on this PC. It runs fine on several other PCs. I have applied every available Windows XP Home update and every available Office 2000 update to no effect. The laptop (set to 32-bit colour) can display digital colour photographs without any problem and ...

Changing a formula's result to text
I have a pretty simple worksheet that lists the date in column A. In column B, I have a formula that converts the date in Column A to the proper day of week. When I put it in a pivot table, it treats column B as an individual date, not the proper DOW. I attempted to copy/paste special/values into a new column, but it doesn't change it to the DOW, it leaves it as the date. I am trying to get Excel to permanently change the cells in column B to say "Tuesday" instead of 4/19/07. Does that make sense? All of the conventional answers don't seem to work for me. Any help? It...

text spilling over text and colums
My text is spilling over the colums and the text. When I change the view from 70% to 75% the text will not show in the row colums, they go out into the white area. If you get this today please feel free to respond. thanks in advanced. Have you tried resizing the column? or perhaps a word wrap? To resize a column at the top by the letter just click the line in between and your mouse pointer should change and allow you drag the column to size. (See pictures 1 and 2) To use the word wrap feature Right-click on the field and select format cells, then click on the alignment tab and you sho...

Line Chart #9
Hi, I have a line chart for month on month data Jan'07 Feb'07 Mar'07 Apr'07 May'07 Jun'08 A 93 99 120 111 85 90 This is the Eg data. Is there a way to show difference in values. For Eg : Jan - Feb there is a +6 difference. Then there is a +11 difference... etc Is there a way i can show this difference on the graph automatically? Other than manually inserting a text box?? Thanks Rajula Please don't multi-post. Cross-post if you must. -- David Biddulph "Rajula" <Rajula@discussions.microsoft.com> wrote in message news:2FBF5AFF-6629-470C-B...

Picture Behind Text
I am trying to place a photo overtop of a text box but it is covering up the text. i want the text to show though the photo. how do i do this? Rob K wrote: > I am trying to place a photo overtop of a text box but it is covering > up the text. i want the text to show though the photo. how do i do > this? ==================================== Which version of Publisher? Place the text box on top of the picture. If you see an unwanted white background behind the text... select the text box and type...Ctrl+T...to make it transparent. -- John Inzer MS Picture It! - Digital ...

Textbox Refresh.
This is a multi-part message in MIME format. ------=_NextPart_000_0006_01CA81A8.50917800 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable G'day to all. I have a form that has three textboxes. txt1 and txt = contain values that the user enters.=20 When the value in one textbox changes, I need the third one to contain = the calculated value of the other two. This I can do, after the submit = button is clicked. What I would like is when the user changes the value in txt1, the = calculation is performed and the result is i...

Text All Capitals
In MSWord, formatting can easily be set so that selected text is always in capitals by Format>Fonts>All Caps. Can text in Excel be similarly formatted? Yes it can be done, but not quite in the same way that Word works. Assuming Column A (ie A1, A2, A3 etc) contains the data you wish to converted to upper case, choose a parallel Column B (ie B1, B2, B3 etc.) and use the formula =UPPER(A1) =UPPER(A2) =UPPER(A3) and so on. -- MartinShort Software Tester ------------------------------------------------------------------------ MartinShort's Profile: http://www.excelforum.com/mem...

Help with formatting text in a textbox
Hi All, I have been trying everything I can think of, and still not getting the results I'm after. I am trying to summarize an order in a textbox, by building a string and assigning it to the caption property of the text box. I create a recordset based on what's in the table, then loop through it and build my string(s). I want to display everything nicely, so I am trying to space each field so that I can put in a header row of labels, and then have each record show nicely spaced below. I am now finding that even when I take into account the length of the data inthe field, I still ca...