rtf text in string variable

  • Thread starter Thread starter Jason C Reynolds
  • Start date Start date
J

Jason C Reynolds

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,
 
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 said:
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...
 
Back
Top