473,327 Members | 1,952 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,327 software developers and data experts.

advanced search in RTB

Hi,

I know now, how to search for a special char. or a word in a RTB control.
But, my question is:

My RTF file is some sort of an index document, there are chapter numbers
and within these chapters, each line is also numbered. For to avoid ambigous
numbers each chapter number is "Bold, 14pts" and each line is "Bold,
superscript, 9pts". (Remark: I can not use letters instead of numbers).

As my program is -working hard- to be a reader for this types of indexes, I
have 2 textbox controls for the user, one is for the chapter number and the
other is for the line numbers -Requested number will be highlighted. When
the user enters the chapter number and line number, e.g. chap. 5, the second
txtbox should look for only the numbers that are inside the chap. 5. For the
time being I try to solve this question, the optimum operability will be
considered later. Help me, please!

Thanks,
--
Cengiz Ulku
cengizu at bluewin.ch
Jul 17 '05 #1
7 2600
In article <3f**********@news.bluewin.ch>, Cengiz Ulku
<ce*****@bluewin.ch> writes
As my program is -working hard- to be a reader for this types of indexes, I
have 2 textbox controls for the user, one is for the chapter number and the
other is for the line numbers -Requested number will be highlighted. When
the user enters the chapter number and line number, e.g. chap. 5, the second
txtbox should look for only the numbers that are inside the chap. 5. For the


I've just learned to my cost that searching an RTB with .SelStart etc.
is *unbelievably* slow,

Possible alternative assuming the list has a fixed layout. Use the
rtb.Text value. Search that line by line for the line starts that you
know will be present, "Chap. 1" then "Chap. 2" etc. Between those search
for line starts "Line 1.", "Line 2." or whatever the format of the line
numbers is.

Might give you a start. If it's possible it should be ~500 times faster
than .SelStart...

Regards.

--
Martin Trump
Jul 17 '05 #2
> I've just learned to my cost that searching an RTB with .SelStart etc.
is *unbelievably* slow,


Look up the Find method in the help files for the RichTextBox control.

Rick - MVP
Jul 17 '05 #3
In article <yb********************@comcast.com>, Rick Rothstein
<ri************@NOSPAMcomcast.net> writes
One thing very nice about the Find method is that it allows searches for
whole words; this allows you to search for the word "the" without finding it


Quite so. Probably useful to the OP seeking "Chap. 1" whatever.

Once again, I live and learn :-)

Regards.

--
Martin Trump
Jul 17 '05 #4
Hi!

Thank you for your help.

My index file is prepared within Word and saved as rtf format using
superscripts. In this case I think I should use the RTF code "\super" for to
find 'em.

Cengiz Ulku
ce*****@bluewin.ch


"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message
news:_Q********************@comcast.com...
I know now, how to search for a special char. or a word in a RTB control. But, my question is:

My RTF file is some sort of an index document, there are chapter numbers and within these chapters, each line is also numbered. For to avoid ambigous
numbers each chapter number is "Bold, 14pts" and each line is "Bold,
superscript, 9pts". (Remark: I can not use letters instead of numbers).

As my program is -working hard- to be a reader for this types of indexes, I
have 2 textbox controls for the user, one is for the chapter number and the
other is for the line numbers -Requested number will be highlighted.

When the user enters the chapter number and line number, e.g. chap. 5, the

second
txtbox should look for only the numbers that are inside the chap. 5. For

the
time being I try to solve this question, the optimum operability will be
considered later. Help me, please!


I wasn't sure how you were doing your superscript as VB doesn't have a
built-in way to apply a **true** RTF superscript. It does allow for a
selection to have its characters offset (in the vertical direction), so I
used that to simulate the superscript for this example. (If you are using

a **true** superscript, applied from another application, then post back and I try to modify this to take that into account.) Anyway, this code should find the Chapter Number, which is bolded, specified in a TextBox named Text1 and Line Number, which is offset a value of 60, specified in a TextBox named
Text2.

Rick - MVP

Dim IFoundIt As Boolean
With RichTextBox1
.SelStart = 0
.Find Text1.Text
If Not .SelBold Then
Do Until IFoundIt
.Find Text1.Text, .SelStart + 1
If .SelBold = True Then IFoundIt = True
Loop
End If
IFoundIt = False
.Find Text2.Text
If .SelCharOffset <> 60 Then
Do Until IFoundIt
.Find Text2.Text, .SelStart + 1
If .SelCharOffset = 60 Then IFoundIt = True
Loop
End If
.SetFocus
End With

Jul 17 '05 #5
Hi,

Thanks a lot for your help!

Let me try to explain what really I want to do. I know how to explain but
not to explain it to VB!!

Remark1: The index file is created by Word, with superscripted line numbers.

Remark2: Form contains 2 TBoxes, One for the chapter number and One for the
line number.

In fact -what I understand is- these two TBoxes should "communicate" between
each other. Text2 should select the text according to Text1's value.

And the file looks like :

chapter 1<bold, 14pts>

1<superscript> reference bla bla bla

2<superscript>bla bla bla....

...

chapter 2<bold, 14pts>

1<superscript>another bla bla...

2<superscript>some sort of bla bla...

....

etc..

In a way that VB understands, what I want VB to understand is: (Roughly)

Chapter = Look for the value in Text1

Line_number= Look for the value in Text2

Put Selection at Chapter

Do find every text (beginning after Chapter)

Highlight Line_numbers which are superscripted

Loop until

Bolded text sized 14pts.

If all these are not clear, sorry for your eyes, please ignore it.

Have a nice day!

--
Cengiz Ulku
ce*****@bluewin.ch

"Cengiz Ulku" <ce*****@bluewin.ch> wrote in message
news:3f**********@news.bluewin.ch...
Hi,

I know now, how to search for a special char. or a word in a RTB control.
But, my question is:

My RTF file is some sort of an index document, there are chapter numbers
and within these chapters, each line is also numbered. For to avoid ambigous numbers each chapter number is "Bold, 14pts" and each line is "Bold,
superscript, 9pts". (Remark: I can not use letters instead of numbers).

As my program is -working hard- to be a reader for this types of indexes, I have 2 textbox controls for the user, one is for the chapter number and the other is for the line numbers -Requested number will be highlighted. When
the user enters the chapter number and line number, e.g. chap. 5, the second txtbox should look for only the numbers that are inside the chap. 5. For the time being I try to solve this question, the optimum operability will be
considered later. Help me, please!

Thanks,
--
Cengiz Ulku
cengizu at bluewin.ch

Jul 17 '05 #6
In article <3f********@news.bluewin.ch>, Cengiz Ulku
<ce*****@bluewin.ch> writes
If all these are not clear, sorry for your eyes, please ignore it.


Cengiz, why not post a few lines of your list here as plain text?

Regards
--
Martin Trump
Jul 17 '05 #7
> My index file is prepared within Word and saved as rtf format using
superscripts. In this case I think I should use the RTF code "\super" for to find 'em.


Okay, what about something like the following code then?

Rick - MVP

Dim Chapter As Long
Dim NextChapter As Long
Dim CurrentSelStart As Long
Dim IFoundIt As Boolean
If Text1.Text Like "*[!0-9]*" Or _
Text2.Text Like "*[!0-9]*" Then
MsgBox "Bad Chapter or Line Number!", _
vbCritical, "Bad Input"
Else
With RichTextBox1
CurrentSelStart = .SelStart
.SelStart = 0
Chapter = .Find(Text1.Text)
If Not .SelBold Then
Do Until IFoundIt
Chapter = .Find(Text1.Text, .SelStart + 1)
If .SelBold = True Then IFoundIt = True
Loop
Else
If Chapter >= 0 Then IFoundIt = True
End If
If IFoundIt Then
CurrentSelStart = .SelStart
.SelStart = .SelStart + .SelLength
Do
NextChapter = .Find(CStr(1 + Val(Text1.Text)), _
.SelStart + 1)
Loop Until .SelBold = True Or NextChapter = -1
.SelStart = CurrentSelStart + .SelLength
.SelLength = 1
Do While InStr(.SelRTF, "\super") = 0
Chapter = .Find(Text2.Text, .SelStart + 1)
If Chapter = -1 Then
.SelStart = CurrentSelStart
.UpTo vbLf, False
Exit Do
End If
Loop
If .SelLength > 0 And Chapter >= NextChapter Then
.SelStart = CurrentSelStart
.UpTo vbLf, False
End If
Else
.SelStart = CurrentSelStart
End If
.SetFocus
End With
End If
Jul 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: nortelsale | last post by:
I know nothing about programming but I am building a website (written with php) that allow people post some info. Is there a site I can get some templates or php scripts for an advanced search...
0
by: Jack | last post by:
Hello, I am looking for some canned scripts to implement an advanced search feature on a product catalog. Here are the details : 1. product has attributes. Depending on the product family, a...
2
by: intl04 | last post by:
Is it possible to create an Access database that searches on multiple fields or can process multiple search keywords (for a photos database) or is it best to just use third-party software such as...
1
by: javawzl | last post by:
I am looking for a 3rd party advanced (SQL) search control that I can basically plug and play into my ASP.Net and supplement with additional fields (like a country drop down). That is, I don't...
0
by: gderosa | last post by:
I have searched for hours regarding this but I am trying to make an advanced search page for my application that has drop downs for 'Greater Than', 'Equals', 'Less Than'. For example the search page...
18
by: dlesandrini | last post by:
Has anyone noticed that the Google Groups Advanced Search no longer works correctly? Is it something I'm doing or have others noticed the change? Used to be, if I put *access* in the Groups...
0
by: =?Utf-8?B?SklNLkgu?= | last post by:
Advanced search function I need to perform search in the articles which are in the SQL database. How can I perform: with all of the words with the exact phrase with at least one of the words...
2
by: Bobby Edward | last post by:
I am creating an Advanced Search form. The user can select whether their phrase will search the "Title", "Description" or "All" fields. Obviously the WHERE clause will change, depending on the...
1
by: BobLewiston | last post by:
I installed SQL Server 2008 Express, basic edition (SQLEXPR32_x86_ENU_Bootstrapper.exe, version 9.0.30729.1) without any problem. Then I attempted to install AdventureWorks Sample Databases for...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.