SOLVED

I try to know which character I am facing

Brass Contributor

Hello,

I am reading pdf information and I already got the text I was looking for, but this one has two characters at the beginning that I can't delete.

Apparently, they are not simple spaces, because the TRIM function did not work for me. I am inquiring about which characters are with ASC, and supposedly they are 10 and 13. Then I replace them with Replace and it doesn't seem to work.

 

Question_Characters.png

Any idea how to fix this please?

Thank you very much for your help and time.

 

2 Replies
best response confirmed by LuisElCaminante (Brass Contributor)
Solution

@LuisElCaminante You've already done everything correct to identify the two leading characters (13 = Carriage Return; 10 = Line Feed), and the Replace method is working. The only mistake you've made is to use documento as the Expression argument when defining dc both times... the second time, dc should have been used as the Expression argument.

 

You really only need one variable, documento, which can be redefined and reduced after each use of Replace. For example:

 

documento = Trim(vector(0))
documento = Replace(documento, Chr(13), "")
documento = Replace(documento, Chr(10), "")

 

Or you can combine all three steps into one line:

 

documento = Replace(Replace(Trim(vector(0)), Chr(13), ""), Chr(10), "")

 

I hope that helps. Cheers!

Thank you very much, sorry for the code, it looks messy like that because I was trying to figure out what was going on.

I inserted a lot of intermediate variables, to try to understand, which I also ended up confusing.

Thank you very much, you gave me light to give me a solution to the problem.
1 best response

Accepted Solutions
best response confirmed by LuisElCaminante (Brass Contributor)
Solution

@LuisElCaminante You've already done everything correct to identify the two leading characters (13 = Carriage Return; 10 = Line Feed), and the Replace method is working. The only mistake you've made is to use documento as the Expression argument when defining dc both times... the second time, dc should have been used as the Expression argument.

 

You really only need one variable, documento, which can be redefined and reduced after each use of Replace. For example:

 

documento = Trim(vector(0))
documento = Replace(documento, Chr(13), "")
documento = Replace(documento, Chr(10), "")

 

Or you can combine all three steps into one line:

 

documento = Replace(Replace(Trim(vector(0)), Chr(13), ""), Chr(10), "")

 

I hope that helps. Cheers!

View solution in original post