Waldemar,
Here is an extention of the LIKE pattern approach, which I find attractive because it makes full use of the inherrent pattern matching capability built into the language, and consequently results in a short and simple but powerful solution.
[tt]
Function FindPatternInString(Strng, LenPattern, Pattern)
'-------------------------------------------------------------
'Locate a wildcard pattern of a certain length in a string.
'Returns the starting position if the pattern is found;
'zero otherwise.
'Not optimised, and assumes implicit declarations of
'variables
'
'Sample invocations:
'
'? FindPatternInString("ABCXXX1-2",3,"[0-9]?[0-9]"

returns 7
'? FindPatternInString("ABCXXX1-2",3,"[A-Z][0-9]?"

returns 6
'? FindPatternInString("ABCXXX1-2",3,"B*"

returns 2
'? FindPatternInString("ABCXXX1-2",3,"BZ?"

returns 0
'-------------------------------------------------------------
matchFound = False
For i = 1 To Len(Strng) - LenPattern + 1
StrngToMatch = Mid(Strng, i, LenPattern)
If StrngToMatch Like Pattern Then
matchFound = True
Exit For
End If
Next i
If Not matchFound Then
FindPatternInString = 0
Else
FindPatternInString = i
End If
End Function
[/tt]
Food for thought,
Cheers,
Steve Lewy
Solutions Developer
steve@lewycomputing.com.au