View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Luc[_3_] Luc[_3_] is offline
external usenet poster
 
Posts: 24
Default Best/Easiest way to search/find in a string

by my opinion, best way of working is

1- use the instr function to see if the string contains the search string
2- use the mid function to copy the data you need


--
Best regards
Luc Nuyts
www.scriptingIT.be


" wrote:

I know a few ways to search or find terms in a string, but what method
is the best/quickest/easiest?

For example, if I have a string and want to find a different string
within that.

I want to see if the string:

"TEMP(302)WPRDRAMT|input_range = "0" "999999.99" ; |MaxInput = 10|"

Contains the string:

"input_range"

And if so I want to extract the terms "0" and "999999.99".

The way I've done this is the past (being new to VBA) is to loop
through the string and pull out substrings in blocks the same length
as the string I'm searching for (using MID) until I get a match, but
is there a SEARCH/FIND etc command in VBA?

I'd then use the " as delimiters to get the two numeric values I'm
after, but again is there a better way than using MID and stepping
through the string character by character?

Thanks.

(I've not explained that very well so please question me if you need
clarification)