I need to fix a procedure I wrote a year ago… I’m trying to parse a string… I need to find the three character month in the string and set a position for it… (This is used to set the Strike later)… Here’s the code I was using…
Public Function ParsePosition(pstrSearch As String) As Integer
‘ This function returns the position that will be used for parsing
‘ the long description field from the WTR or DTR
Select Case True
Case InStr(6, pstrSearch, ” JAN”)
ParsePosition = InStr(6, pstrSearch, ” JAN”)
Case InStr(6, pstrSearch, ” FEB”)
ParsePosition = InStr(6, pstrSearch, ” FEB”)
Case InStr(6, pstrSearch, ” MAR”)
ParsePosition = InStr(6, pstrSearch, ” MAR”)
Case InStr(6, pstrSearch, ” APR”)
ParsePosition = InStr(6, pstrSearch, ” APR”)
Case InStr(6, pstrSearch, ” MAY”)
ParsePosition = InStr(6, pstrSearch, ” MAY”)
Case InStr(6, pstrSearch, ” JUN”)
ParsePosition = InStr(6, pstrSearch, ” JUN”)
Case InStr(6, pstrSearch, ” JUL”)
ParsePosition = InStr(6, pstrSearch, ” JUL”)
Case InStr(6, pstrSearch, ” AUG”)
ParsePosition = InStr(6, pstrSearch, ” AUG”)
Case InStr(6, pstrSearch, ” SEP”)
ParsePosition = InStr(6, pstrSearch, ” SEP”)
Case InStr(6, pstrSearch, ” OCT”)
ParsePosition = InStr(6, pstrSearch, ” OCT”)
Case InStr(6, pstrSearch, ” NOV”)
ParsePosition = InStr(6, pstrSearch, ” NOV”)
Case InStr(6, pstrSearch, ” DEC”)
ParsePosition = InStr(6, pstrSearch, ” DEC”)
End Select
End Function
Problem: Some records have descriptions like this…
PUT BK NOVA SCOT DEC 065
PUT BK NOVA SCOT NOV 065
CALL BK NOVA SCOT NOV 070
There is not always a space after the NOV, before the numeric value either…
CALL BK NOVA SCOT NOV110 1/2
InStr finds the first occurance… I want to either be more specific… like ask for … space, MMM value, # value OR space, MMM, space, # (…but I can’t use wildcard characters with InStr()…) OR maybe find the last occurance in the string rather than the first…
Does anyone have any ideas of how I could accurately do this?? TIA!