473,395 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 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 2899
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Paweł | last post by:
Hello! I'm looking for efficient code or site where I can find code for finding one string in another string. String which I search should have "wild" characters like '?' for any one char and...
2
by: Fraser Ross | last post by:
I want to use std::find_if to find the first char of a sequence that is not a digit. Can this be done the STL components alone? I can use a predicate functor written myself like this: struct...
5
by: Robert Manea | last post by:
Hello everyone, I wrote, simply as an exercise, a small piece of code to find 'strings' (defined as an amount of at least 3 ASCII characters followed by a non ASCII character) in binary files. ...
11
by: spideyman99 | last post by:
How can I find the true EOF for a file that contains 0xFF. When I use fgetc and it encounters 0xFF it thinks it's the end of file but it really isn't.
21
by: newlang | last post by:
Hello everyone, I am eager to know about string functions, (user defined) . tell me the technique of find a string in another string.
6
by: Tarun | last post by:
Hi All, I need to find a particular substring in a binary string(some text appended & prepended to binary data). I cant use strstr since it terminates on receiving '\0'which can be there in...
14
by: prasadjoshi124 | last post by:
Hi All, I am writing a small tool which is supposed to fill the filesystem to a specified percent. For, that I need to read how much the file system is full in percent, like the output given...
12
by: Sankar | last post by:
Dear all, I am programming in Linux , wherein I need to know a couple of things. 1) Does an API exist that can copy file onto another file ( an API equivalent of 'cp') ? 2) Is there an API...
7
by: DarthBob88 | last post by:
I have to go through a file and replace any occurrences of a given string with the desired string, like replacing "bug" with "feature". This is made more complicated by the fact that I have to do...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.