temps(X) = "set port name *** DESCRIPTION *** *** PORT *** "
first = InStr(temps(x), "***") ' find start postition
last = InStr(InStr(1, temps(x), "***") + 1, temps(x), "***") 'find end
snip = Mid(temps(x), first, last)
MsgBox (snip)
Why does this result in the out put
*** DESCRIPTION *** *** PORT **
and not the expected *** DESCRIPTION ***
Cheers
Aaron
instrtakes the parameters asstring,startpos,len… so it’s failing because you’ve assumed the parameters are:string,startpos,endpos.You can fix your code by doing this instead:
Note as well that your construct:
can be written more simply. Note that you’ve already done
Instr(1, temps(s), "***")once when you got the value forfirst, so you can rewrite that line to the much more simple: