By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,573 Members | 1,797 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,573 IT Pros & Developers. It's quick & easy.

rtf text in string variable

P: n/a
Hi, I've came up short on an answer to this:
Is there a way to find out if a string variable contains valid rtf text? I
got around by trapping the error and just setting the .text property instead
of the .rtf property of my richTextBox. But I would like to know (to
prevent the exception) if the string variable contains valid rtf data.

Any suggestions?
Thanks,

--
Jason
Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi Jason, try this:

Public Function IsRTF(ByVal strText As String) As Boolean
Return strText.StartsWith("{\rtf1")
End Function

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations
"Jason C Reynolds" <jr********@Xthewritesource.com> wrote in message
news:uQ**************@tk2msftngp13.phx.gbl...
Hi, I've came up short on an answer to this:
Is there a way to find out if a string variable contains valid rtf text? I got around by trapping the error and just setting the .text property instead of the .rtf property of my richTextBox. But I would like to know (to
prevent the exception) if the string variable contains valid rtf data.

Any suggestions?
Thanks,

--
Jason

Nov 20 '05 #2

P: n/a
"Jason C Reynolds" <jr********@Xthewritesource.com> scripsit:
Hi, I've came up short on an answer to this:
Is there a way to find out if a string variable contains valid rtf text? I
got around by trapping the error and just setting the .text property instead
of the .rtf property of my richTextBox. But I would like to know (to
prevent the exception) if the string variable contains valid rtf data.


I think the way you mentioned is the easiest solution...

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.