In string

  • Thread starter Thread starter Vina
  • Start date Start date
V

Vina

Hello,

can someone let me know how i can create a function that
it will look in a field and take the characters that are
between a specific character, the field with VWORDS THAT
I NEED S. I want all the words or character between V & S.

Any help is very much appreciated.

Thanks
Vina
 
Hello,

can someone let me know how i can create a function that
it will look in a field and take the characters that are
between a specific character, the field with VWORDS THAT
I NEED S. I want all the words or character between V & S.

Any help is very much appreciated.

Thanks
Vina

InStr() will find a string; Mid() will extract a substring.

If you use

Mid([field], InStr([field], "V"), InStr([field], "S"))

you'll get the string between the first V and the first S: to wit,
WORD. I have no notion how you would distinguish the S that you intend
as the string terminator from any arbitrary number of S's inside the
desired string.
 
The following (untested air-code) should give you everything between the
first occurrence of "v" and the last occurrence of "s" in a string

Public Function FindVS(strInput As String) As String

FindVS = Mid(strInput, InStr(strInput, "v") + 1, InStrRev(strInput, "s") -
InStr(strInput, "v") - 1)

End Function
 
What do you want to happen if:

- there is no V?

- there are several Vs?

- there is no S?

- there are several Ss?

- the first S comes before (not after) the first V?

There's no point trying to write any code, until you tell us what you want
to happen in those cases.

TC
 
Back
Top