|
|
|
Click here to copy the following block |
Enum sepType specialSep = 0 spacesOnly = 1 spacesAndSymbols = 3 spacesSymbolsAndCtrl = 7 spacesSymbolsCtrlAndDigits = 15 End Enum
Function InstrWordEx(Start As Long, Source As String, Find As String, _ compareMethod As VbCompareMethod, Optional separatorType As sepType = _ spacesSymbolsCtrlAndDigits, Optional Separator As String = vbNullString) As _ Long Dim index As Long Dim charcode As Integer Dim separatorInvalid As Boolean
InstrWordEx = 0
index = Start - 1
Do index = InStr(index + 1, Source, Find, compareMethod) If index = 0 Then Exit Function
If index > 1 Then charcode = Asc(UCase$(Mid$(Source, index - 1, 1))) Else charcode = 32 End If
If IsValidChar(charcode, separatorType, Separator) Then charcode = Asc(UCase$(Mid$(Source, index + Len(Find), 1)) & " ") If IsValidChar(charcode, separatorType, Separator) Then InstrWordEx = index Exit Function End If End If Loop
End Function
Private Function IsValidChar(char As Integer, separatorType As sepType, _ Separator As String) Dim charType As Integer
If separatorType = specialSep Then IsValidChar = (char = Asc(UCase$(Separator))) Exit Function End If
Select Case char Case Is < 32 charType = 4
Case 32 charType = 1
Case Is < 48, Is > 90 charType = 2
Case Is < 58 charType = 8
Case Is < 65 charType = 2
Case Else charType = 0 End Select
IsValidChar = Not ((charType And separatorType) = 0) End Function |
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
|
|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|