Solved

Length of a Richtext printed string

Posted on 2004-04-26
5
640 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month3 days, 21 hours left to enroll

630 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