I need to find the character " into text
I have used InStr(strLine,""") but it doesn't run and gives me an error:
800a0409 unterminated string constant
Where is my mistake?
I need to find the character " into text
I have used InStr(strLine,""") but it doesn't run and gives me an error:
800a0409 unterminated string constant
Where is my mistake?
What you want to do is use two quote characters in a row, not just one:
InStr(strLine,"""")
This is how it breaks down: the first " character is how you start a string constant; the second and third " characters together are called an "escaped" quote and indicate that you are not ending the string constant but are instead including a literal, single " character; the fourth " character is the final one indicating that you are ending the string constant.
You must always have an even number of quote characters " as a rule to avoid the compiler error you received.
As an alternative, you could also do it like this:
InStr(strLine, Chr(34))
The Chr() method takes an ASCII value for a character and returns that character. The ASCII value for the double-quote character " is 34.
Which approach you choose is up to you and depends on the circumstances. I usually go with the escaped, double-double-quote "" because it's easier to code and easier to read in longer string constants.