Hi All,
I have a variable length string that I pass into a strVariable. Within the string there are two instances of a five-character string.
Dim StrVariable as String
Dim intBeginHere as Interger
Dim intBeginWhere as Interger
Dim intNewPosition as Interger
Dim str1stPart As String
Dim str2ndPart As String
StrVariable = “abcdefg XXXXX hijklmnop XXXXX qrstuvwxyz” ‘Can be between 175 and 200 characters.
intBeginHere = CInt(InStr(StrVariable, “XXXXX”) – 1)
str1stPart = Left(StrVariable, intBeginHere)
Debug.Print str1stPart
‘Up to this point everything works fine.
intBeginWhere = intBeginHere + 6
‘I must be missing something because here is where the problem begins. The below InStr() function is _
not returning the correct number of characters beginning at intBeginWhere until if finds the next _
“XXXXX”. It seems to be adding all the characters from position one. I’ve checked the help file _
and the example it gives indicates I should be able to do this. Any ideas why this is not working?
intNewPosition = CInt(InStr(intBeginWhere, StrVariable, “XXXXX”) – 1)
Debug.Print intNewPosition
‘I even tried