Visual Basic (VB and VBA)

Copyright 1999-2001 Christopher Greaves. All rights reserved.
Home Page and email to [email protected]
If in doubt, record a macro and inspect the entrails!

 

 

Please read the DISCLAIMER.

Here is an INDEX to all the procedures.

You will probably need one copy of my GLOBAL DECLARATIONS.



Public Function lngOrInstr(Start As Long, MainString As String, Charset As String) As Long
' Procedure :   lngOrInstr
' Description:  Return the first occurence of any character of one string in another
' Copyright:    Chris Greaves Inc.
' Inputs:       LONG start point(1), STRING to be serached, STRING of chars being sought.
' Returns:      LONG
' Assumes:      Nothing
' Side Effects:
' Tested:       By the calls listed below.
'VBA 's built-in "Like" operator is always worth exploring for matching a character against a set of alternatives.
'For example,
'Could be used to look for the first vowel in the word "hello". (The set of characters needs to be enclosed in square brackets"
'OrInstr(1,"hello","[aeiou]")
'Good luck !
'Xiao Bin
    Dim iChar As Long
    For iChar = Start To Len(MainString)
        If Mid$(MainString, iChar, 1) Like Charset Then
            lngOrInstr = iChar
            Exit Function
        End If
    Next
'Sub TESTOrInstr()
'MsgBox lngOrInstr(1, "christopher greaves", "[aeiou]")
'MsgBox lngOrInstr(1, "christopher greaves", "[aeou]")
'End Sub
End Function

We all knew nothing when we started …
Home Page and Contact Information
Send email to [email protected].
This page was last updated Thursday, November 15, 2001

 

 

Hosted by www.Geocities.ws

1

Visual Basic (VB and VBA)

Copyright 1999-2001 Christopher Greaves. All rights reserved.
Home Page and email to [email protected]
If in doubt, record a macro and inspect the entrails!

 

 

Please read the DISCLAIMER.

Here is an INDEX to all the procedures.

You will probably need one copy of my GLOBAL DECLARATIONS.

Public Function lngOrInstr(Start As Long, MainString As String, Charset As String) As Long
' Procedure :   lngOrInstr
' Description:  Return the first occurence of any character of one string in another
' Copyright:    Chris Greaves Inc.
' Inputs:       LONG start point(1), STRING to be serached, STRING of chars being sought.
' Returns:      LONG
' Assumes:      Nothing
' Side Effects:
' Tested:       By the calls listed below.
'VBA 's built-in "Like" operator is always worth exploring for matching a character against a set of alternatives.
'For example,
'Could be used to look for the first vowel in the word "hello". (The set of characters needs to be enclosed in square brackets"
'OrInstr(1,"hello","[aeiou]")
'Good luck !
'Xiao Bin
    Dim iChar As Long
    For iChar = Start To Len(MainString)
        If Mid$(MainString, iChar, 1) Like Charset Then
            lngOrInstr = iChar
            Exit Function
        End If
    Next
'Sub TESTOrInstr()
'MsgBox lngOrInstr(1, "christopher greaves", "[aeiou]")
'MsgBox lngOrInstr(1, "christopher greaves", "[aeou]")
'End Sub
End Function

We all knew nothing when we started …
Home Page and Contact Information
Send email to [email protected].
This page was last updated Thursday, November 15, 2001

 

 

Hosted by www.Geocities.ws

1