dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: VB4,VB5,VB6,VBS
Expertise: Intermediate
Feb 26, 2000

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


InstrWord - Search a whole word

' Return the next occurrence of a whole word

Function InstrWord(start, Text, search, compareMethod) As Long
    Dim index As Long
    Dim charcode As Integer
    
    ' assume the search fails
    InstrWord = 0

    index = start - 1
    
    Do
        ' search the next occurrence, exit if not found
        index = InStr(index + 1, Text, search, compareMethod)
        If index = 0 Then Exit Function
        
        ' check that it is preceded by a punctuation symbol
        If index > 1 Then
            charcode = Asc(UCase$(Mid$(Text, index - 1, 1)))
        Else
            charcode = 32
        End If
        If charcode < 65 Or charcode > 90 Then
            ' check that it is followed by a punctuation symbol
            charcode = Asc(UCase$(Mid$(Text, index + Len(search), 1)) & " ")
            If charcode < 65 Or charcode > 90 Then
                InstrWord = index
                Exit Function
            End If
        End If
    Loop

End Function
Francesco Balena
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date