a6m1n0,
I would like to point out that the VB functions Right, Left, Mid, and InStr are perfect for parsing strings since it is the function's intended use.
I was pointing out the potential flaw in the code that both you and George posted.. not to criticise, but to warn Michelle that if she had "or" in the text more than twice (e.g. hidden in a w[!]or[/!]d) she would not get what she expected. I gave examples to demonstrate this clearly.
The point of this was to show that the value to "split/separate" should be reviewed - which you have subsequently changed in the code in your last post. Which is good.
However, the issue now lies with the fact that " or " could occur more than once in the string (again we don't know for sure as Michelle has provided no sample data, only a derived question). If it does, then the instr method will find the position it first finds the value in, which may not be the one Michelle wants.
It is hard to get one's head wrapped around it and is why sometimes people use Split() instead--it's fewer lines of code and it is in most cases more convenient
Not really, left, right, mid are some of the most basic functions of the language, and instr isn't particularly difficult. I think most if not all programmers will know how these are generally supposed to work. Michelle showed knowledge of the functions, just wanted clarity - and in fact actually fixed it herself anyway.
I am not arguing one way is better than the other as I don't really know and can't say.
It depends on the situation and the desired output. if you want a single string output taking from the first occurance of the separator value, then the string manipulation functions will be the best option.
However if you expect to have multiple (and variable) occurances of the separator, and either want to cycle through the list of them (to dynamically build SQL statements for example) or would always like to get the last bit (or the most right as per the OPs request) then split is a better option as it returns an array you do array like things with. You can of course use revinstr to get the rightmost occurance aswell, but it will still only return 1 value unless you start creating unecessary loops or worse, recursive functions.
Also, the OP did ask specificaly for information regarding the contents left of a keyword in a string and using the these VB functions
sorry to be a little pedantic, but she asked for the information to the right implicitly by saying "Please can anyone tell me what function or how to [!]remove[/!] all the characters and spaces to the [!]left[/!] of this string?". And also asked which function to use, rather than saying it must be x, y or z.
Also, answering a question on face value is like developing application code from a users Request For Change - first rule of analysis is to find the need behind the need - what are they really needing, as opposed to what they're asking for - it is also the number 1 rule of professional selling.. why ? because people add their own understanding and interpretations to what their requirements are and don't necessarily tell the 'experts' they're asking what is really needed (usually because they don't know.. that's what they're paying you for!) - it is the 'experts' job to investigate and understand the real issue and need, and thus requirement before providing an answer. Otherwise you play "follow the scope" where the customer/TT Poster/whatever finds every answer you give either wrong, or not quite right. A part of Requirements Management, but it is useful in everyday life too.
Hope that helps to clarify without being too critical.
I doubt the OP is even reading anymore, she probably finished her app and is preparing the next release!
A smile is worth a thousand kind words. So smile, it's easy! 