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
Solved

Length of a Richtext printed string

Posted on 2004-04-26
5
636 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Microsoft Access combo box help 2 49
Question about INSTR  - need to extract data MS ACCESS query 6 59
message box in access 4 51
Add a task in Outlook from access 11 42
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 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…
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…

856 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