Solved

Length of a Richtext printed string

Posted on 2004-04-26
5
633 Views
Last Modified: 2009-07-29
I need to determine the length of a Richtext string, but I only want to count the characters that actually print.  

Using the Len() function, I can determine the length of a Richtext string, but the calculation includes a long list of non-printing Richtext formatting characters (e.g. "{\rtf1\ansi\ansicpg-1\...").  Generally there appears to be 115 non-printing characters, but I've also seen 126.  I assume this is a dynamic value based on the type and amount of formatting that the user applies to the text.

Is there a way to avoid counting the formatting characters when calculating the string length?

Thanks, T.C.
0
Comment
Question by:TSClark251
  • 2
  • 2
5 Comments
 
LVL 9

Expert Comment

by:leechoonhwee
ID: 10926729
Well if the formatting is forseeable, then probably you can apply some filter before counting the len.eg

presume strtext = "{\rtf1\ansi\ansicpg-1\xxx}"

assuming xxx is the len you want to count then wat you can do is

For i = 1 to len(strtext)
strTemp = right(strtext,i)
if strtemp = "\" then
Strlength = len(strTemp)
exit for
end if
next

You can alter the filter to the pattern that you need. Hope it explains.





0
 
LVL 7

Accepted Solution

by:
OHDev2004 earned 250 total points
ID: 10927162
doesn't Len(Richtextbox1.text) do the trick ??
because there are two options for the text
Richtextbox1.Text 'to get the plaintext
Richtextbox1.TextRtf 'to get the RtfText
OHDev2004
0
 

Author Comment

by:TSClark251
ID: 10937002
OHDev2004,

Thanks...your suggestion helped me solve the problem.  

Respectfully,
T.C.
0
 

Author Comment

by:TSClark251
ID: 10937009
leechoonhwee,

Thanks for the input.

T.C.
0
 
LVL 7

Expert Comment

by:OHDev2004
ID: 10938163
your welcome :)
OHDev2004
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now