Find Text Function Using Wildcards 
Author Message
 Find Text Function Using Wildcards

Hi Tim,

From Ian's response I assume the Like operation is a VB 6
feature/enhancement.

But for your information here's a snippet fromVB6 help example:

Dim MyCheck
MyCheck = "aBBBa" Like "a*a"   ' Returns True.
MyCheck = "F" Like "[A-Z]"   ' Returns True.
MyCheck = "F" Like "[!A-Z]"   ' Returns False.
MyCheck = "a2a" Like "a#a"   ' Returns True.
MyCheck = "aM5b" Like "a[L-P]#[!c-e]"   ' Returns True.
MyCheck = "BAT123khg" Like "B?T*"   ' Returns True.
MyCheck = "CAT123khg" Like "B?T*"   ' Returns False.

where it supports * and ? and # (number) and other Unix Grep-like patterns.

Cheerio,
ian Laing


Quote:
> Hi, I am looking for a function in which you can search a string using
> wildcards such as "*". For instance in the text search string "*cat*", the
> following words would be found as matching:

> cat
> catnip
> alleycat
> nocategory
> etc.......

> I'm using VB5. The search sub I am using looks only for exact matches,
here
> is the code:

> Private Sub FindText(ByVal start_at As Integer)

> Dim pos As Integer
> Dim target As String

>     target = txtTarget.Text
>     pos = InStr(start_at, txtBody.Text, target)
>     If pos > 0 Then
>         ' We found it.
>         TargetPosition = pos
>         txtBody.SelStart = TargetPosition - 1
>         txtBody.SelLength = Len(target)
>         txtBody.SetFocus
>     Else
>         ' We did not find it.
>         MsgBox "Not found."
>         txtBody.SetFocus
>     End If
> End Sub

> Any help is appreciated.

> Thanks,
> Tim Hirtle

> -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
> http://www.*-*-*.com/ - The #1 Newsgroup Service in the World!
> -----==  Over 80,000 Newsgroups - 16 Different Servers! =-----



Sun, 23 Feb 2003 03:22:23 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Wildcards finding long numbers within text .

2. Using the /1 wildcard found fields

3. Trouble finding files using wildcards

4. using find with wildcards on an ado recordset

5. Function like InStr using wildcards?

6. Searching text string variables using wildcard characters

7. Writing Find and Replace Dialogs using RichTextBox.Find Function

8. textwidth() function when text is to be printed using the tab() function

9. Find various text and copy the found text into different document

10. I want give a text out to my speakers , Cant find functions

11. Basic function for find text in a string?

12. Wildcard find and replace

 

 
Powered by phpBB® Forum Software