We help IT Professionals succeed at work.

Identifying unknown character in text file

jackjeckyl
jackjeckyl asked
on
Hi, I have a text file that I need to split into numerous lines but the sepeartor is not a vblf or vbcr or vbcrlf.  I don't know what it is.  It comes across as a box in notepad.  How can I found out what it is so I can split the file into a format I can use?
Comment
Watch Question

Commented:
Copy and paste the character into a vb project that just has a textbox.  Place a button on the form and within the code for the button put.

dim i as integer

for i = 1 to len(text1)
   debug.print mid(text1, i, 1) & " - " & asc(mid(text1, i, 1)
next i
' the for statement is just in case you paste more than one character.

This will display the ascii value of the character in question.

Hope this helps.
Top Expert 2005

Commented:
You can use the Immediate window to determine which character this is:

?asc(vblf)
 10
?asc(vbcr)
 13
?asc(<the mystery character here>)
 
Commented:

Commented:
I play with file formats a lot actually, and one of the best tools in my opinion is good 'ole Microsoft Edit...  pull up a DOS prompt and type "edit /070 <filename>"  The '/070' tells edit to open the file in binary mode with a line width of 70 characters (the leading 0 is important)

By doing it this way, you can browse through the file, make changes to it, while not losing any special characters that notepad throws away.  If you move the cursor over the characters in question, you can then look at the bottom right corner of the edit screen and see the character code for it, in decimal.  Then to check for that character later in VB code, just use the Instr() command... for example, if the file uses a Null (character code=0) as a seperator, you could find the first separator in a file using:


Open strFile For Binary As 1

strData = LOF(1)
Get #1, , strData
nPos = Instr(1, strData, chr(0))

Commented:
Most likely it's a tab character (chr$(9)=vbTab), but the above methods should show you the code number for it.
Well, if all you want to do is read the document, then just open it up in word. Word recognizez this character as a line break.

Regards,

Author

Commented:
That'll work, thank you.
do i get the points ?!?!

Regards,
do i get the points ?!?!

Regards,

Explore More ContentExplore courses, solutions, and other research materials related to this topic.