471,084 Members | 1,033 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,084 software developers and data experts.

Finding specific char in a rtf file

Hi,

I've already posted a question similar but will need some precisions and
help.

I have a rtf file displayed within a RTB control. Above it, I have a text
box control with a scroller which helps me to increase/decrease numbers
inside it by clicking. (There should be a shorter name for this control!!!)

What I want is: Whenever I click the increase the number button, the
concerned number within my rtf file is selected. The numbers to be selected
are fonts with superscripts not normal fonts. So When I increase the numbers
from 1 to whatever the program will select the superscripted number but not
any other number which may exist in normal form.

If this question is clear, thanks for your replies in advance!
if not please ignore it!
--
Cengiz Ulku
ce*****@bluewin.ch
Jul 17 '05 #1
4 2808
Alright, try this code....

With RichTextBox1
CurrentPosition = .SelStart
.SelStart = 0
.SelLength = 1
Do While InStr(.SelRTF, "\super") = 0
Position = .Find(Text1.Text, .SelStart + 1)
If Position = -1 Then
.SelStart = CurrentPosition
Exit Do
End If
Loop
.SetFocus
End With

The above **only** finds the first occurrence if there are multiple
occurrences of the number in your TextBox. You didn't say whether there
could be multiple occurrences of the same number in superscript and whether
you needed to find all of them. I'm going to sleep in a couple of minutes,
so I can't look for a solution of that right now. If you need that, post
back saying so.

Rick - MVP

"Cengiz Ulku" <ce*****@bluewin.ch> wrote in message
news:3f********@news.bluewin.ch...
Thank you Rick!

My Rtf file is not written within my program's RTB control, the file is
written by Word and saved as rtf. As an abnormal char I have only these
superscripts which needs to be found and highlighted when the user looks for it.

Here is what the text looks like:
^1 Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
^2 sed diem nonummy nibh euismod tincidunt ut lacreet dolore magna aliguam
erat volutpat. Ut wisis enim ad minim veniam
^3 quis nostrud exerci tution ullam corper suscipit lobortis nisi ut aliquip ex ea commodo consequat. Duis te feugi facilisi. Duis autem dolor
etc...

Thanks a lot in advance!
Cengiz Ulku
ce*****@bluewin.ch
"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message
news:f-********************@comcast.com...
I've already posted a question similar but will need some precisions and help.

I have a rtf file displayed within a RTB control. Above it, I have a text box control with a scroller which helps me to increase/decrease numbers inside it by clicking. (There should be a shorter name for this control!!!)

What I want is: Whenever I click the increase the number button, the
concerned number within my rtf file is selected. The numbers to be

selected
are fonts with superscripts not normal fonts. So When I increase the

numbers
from 1 to whatever the program will select the superscripted number
but not
any other number which may exist in normal form.


If you are using the SelCharOffset property to establish your superscript, then I would think code something like this will find the first occurrence of a character specified in Text1 that has its SelCharOffset property

set to
anything other than zero. You can use this as a base in case you have to

do
multiple consecutive selections or whatever.

Dim Position As Long
Dim CurrentPosition As Long
With RichTextBox1
CurrentPosition = .SelStart
.SelStart = 0
.SelLength = 1
Do While .SelCharOffset = 0
Position = .Find(Text1.Text, .SelStart + 1)
If Position = -1 Then
.SelStart = CurrentPosition
Exit Do
End If
Loop
.SetFocus
End With

Rick - MVP


Jul 17 '05 #2
Thanks really a lot Rick, you helped me as I'm a novice programmer.

If you can guide me to a link (if it exists)so that I can learn more details
about the usage of these RTF codes (like \super, \b etc..) because the msdn
library cd's do not supply clear info for such beginner...

Have a nice day!
--
Cengiz Ulku
ce*****@bluewin.ch


----------------------------------
"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message
news:dd********************@comcast.com...
Alright, try this code....

With RichTextBox1
CurrentPosition = .SelStart
.SelStart = 0
.SelLength = 1
Do While InStr(.SelRTF, "\super") = 0
Position = .Find(Text1.Text, .SelStart + 1)
If Position = -1 Then
.SelStart = CurrentPosition
Exit Do
End If
Loop
.SetFocus
End With

The above **only** finds the first occurrence if there are multiple
occurrences of the number in your TextBox. You didn't say whether there
could be multiple occurrences of the same number in superscript and whether you needed to find all of them. I'm going to sleep in a couple of minutes,
so I can't look for a solution of that right now. If you need that, post
back saying so.

Rick - MVP

"Cengiz Ulku" <ce*****@bluewin.ch> wrote in message
news:3f********@news.bluewin.ch...
Thank you Rick!

My Rtf file is not written within my program's RTB control, the file is
written by Word and saved as rtf. As an abnormal char I have only these
superscripts which needs to be found and highlighted when the user looks

for
it.

Here is what the text looks like:
^1 Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
^2 sed diem nonummy nibh euismod tincidunt ut lacreet dolore magna aliguam
erat volutpat. Ut wisis enim ad minim veniam
^3 quis nostrud exerci tution ullam corper suscipit lobortis nisi ut

aliquip
ex ea commodo consequat. Duis te feugi facilisi. Duis autem dolor
etc...

Thanks a lot in advance!
Cengiz Ulku
ce*****@bluewin.ch
"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message
news:f-********************@comcast.com...
> I've already posted a question similar but will need some precisions and > help.
>
> I have a rtf file displayed within a RTB control. Above it, I have a

text
> box control with a scroller which helps me to increase/decrease numbers > inside it by clicking. (There should be a shorter name for this
control!!!)
>
> What I want is: Whenever I click the increase the number button, the
> concerned number within my rtf file is selected. The numbers to be
selected
> are fonts with superscripts not normal fonts. So When I increase the
numbers
> from 1 to whatever the program will select the superscripted number but not
> any other number which may exist in normal form.

If you are using the SelCharOffset property to establish your superscript, then I would think code something like this will find the first occurrence of a character specified in Text1 that has its SelCharOffset property

set
to
anything other than zero. You can use this as a base in case you have

to do
multiple consecutive selections or whatever.

Dim Position As Long
Dim CurrentPosition As Long
With RichTextBox1
CurrentPosition = .SelStart
.SelStart = 0
.SelLength = 1
Do While .SelCharOffset = 0
Position = .Find(Text1.Text, .SelStart + 1)
If Position = -1 Then
.SelStart = CurrentPosition
Exit Do
End If
Loop
.SetFocus
End With

Rick - MVP



Jul 17 '05 #3
Don
On Mon, 11 Aug 2003 19:26:04 +0200, "Cengiz Ulku" <ce*****@bluewin.ch> wrote:
Thanks really a lot Rick, you helped me as I'm a novice programmer.

If you can guide me to a link (if it exists)so that I can learn more details
about the usage of these RTF codes (like \super, \b etc..) because the msdn
library cd's do not supply clear info for such beginner...
So what else is new, beginner to old timer, it is the same problem with MSDN..
Even M$ most likely doesn't use it... ;->

Have a nice day!


Have a good day...

Don
Jul 17 '05 #4

"Cengiz Ulku" <ce*****@bluewin.ch> wrote in message
news:3f**********@news.bluewin.ch...
Thanks really a lot Rick, you helped me as I'm a novice programmer.

If you can guide me to a link (if it exists)so that I can learn more details about the usage of these RTF codes (like \super, \b etc..) because the msdn library cd's do not supply clear info for such beginner...

Have a nice day!
--
Cengiz Ulku
ce*****@bluewin.ch

This might help.
http://msdn.microsoft.com/library/de...ml/rtfspec.asp
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Fraser Ross | last post: by
5 posts views Thread by Robert Manea | last post: by
11 posts views Thread by spideyman99 | last post: by
21 posts views Thread by newlang | last post: by
6 posts views Thread by Tarun | last post: by
7 posts views Thread by DarthBob88 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.