473,548 Members | 2,683 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2907
Alright, try this code....

With RichTextBox1
CurrentPosition = .SelStart
.SelStart = 0
.SelLength = 1
Do While InStr(.SelRTF, "\super") = 0
Position = .Find(Text1.Tex t, .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*****@bluewi n.ch> wrote in message
news:3f******** @news.bluewin.c h...
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.c om...
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.Tex t, .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******** ************@co mcast.com...
Alright, try this code....

With RichTextBox1
CurrentPosition = .SelStart
.SelStart = 0
.SelLength = 1
Do While InStr(.SelRTF, "\super") = 0
Position = .Find(Text1.Tex t, .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*****@bluewi n.ch> wrote in message
news:3f******** @news.bluewin.c h...
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.c om...
> 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.Tex t, .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*****@bluewi n.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*****@bluewi n.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
3126
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 '*' for any string of characters. I'm looking for way to effective getting string from text file and then searching it like I write above. Thanks...
2
2003
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 Is_digit : std::unary_function<char, bool> { bool operator()(const char character) const { return character>='0' && character<='9'; }; };
5
5805
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. The purpose of the program is to serve as a facile 'strings' (Unix command) replacement and to be 100% ANSI C. Unfortunatelly it operates notedly...
11
4465
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
2022
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
7556
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 binary data also I cant use memmem. Is there any other available function to do this. Regards Tarun
14
2785
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 by df -k lopgod10:~/mycrfile # df -k /mnt/mvdg1/vset Filesystem 1K-blocks Used Available Use% Mounted on
12
2400
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 that tells me the disk usage ( equivalent for cmdline
7
4901
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 this with a lot of replacements and by the fact that some of the target strings are two words or more long, so I can't just break up the file at...
0
7512
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7438
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7707
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7803
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5082
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3495
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3475
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1051
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
751
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.