Hi, Barry. As always in programming, there's more than one way to do this. You can do it manually with the InStr function. You can use the Split function (good more more than just space-delimited words). You can also use Regular Expressions, which is an advanced topic but can be very useful when your pattern-recognition needs are complex.
Let me ask about a couple of sample cases:
"123/456/789/abc/def": You want to extract "456".
"Now is the/time for all/good men...///": You want "time for all".
"$4,213.99/N": You want "".
But what about these:
"///": ""?
"tuhe/N/thueat": ""?
"$4,213.99/": ""? The same whether there's an 'N' or not, in other words?
If I'm guessing right in the above three cases, then it seems to me the simplest way to do this is to use the Split function, like this:
' As the code begins, StrVal = "something/something/something..."
arr = Split(StrVal, "/") 'creates an array starting with arr(0)
Value2 = arr(1) 'the second value
If Value2 = "N" then Value2 = ""
If you see a problem with any of my test questions, then maybe some other logic would have to be used.
/* Standard warning: I haven't tested this logic, I'm just spinning it up off the top of my head. Test before trusting. */
|