Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

line input string limitation in excel

Status
Not open for further replies.

mmsu

Programmer
Jun 14, 2005
5
US
Hi,

I am importing a txt to excel using Line Input syntax and I came accross a string which have so many characters and I found out that the maximum number of characters that a line string can accept is 280. My question is, is there any way we can increase this number to say 1000?

Thanks in advance.

mmsu
 
I think your problem is that sokme of your data lines contain embedded carriage return / line feed characters - Chr$(13) and Chr$(10)

I created a test file in Notepad, containing lines of alphabetic characters up to 2,048 characters long. I was able to read these using Line Input, with no problems. If you want to try this test, create a command button in an Excel workbok, and add this code to it:
Code:
Private Sub CommandButton1_Click()

Dim InFile As Integer
Dim strOneLine As String

InFile = FreeFile
Open "InputTest.txt" For Input As #InFile

Do
    Line Input #InFile, strOneLine
    MsgBox Len(strOneLine)
Loop Until EOF(InFile)

End Sub
Create InputTest.txt using Notepad, and save it to the same folder as your test workbook.

When you click the button, the first line of text will be read from the file, and a message box will display the length of this line. The process repeats until the end of the file is reached.

You can use this to check your actual text - get the message box to display each line, rather than the length of the line. If you see only part of what you believe is an input line, then that line contains an unwanted chr$(13) character. For example, if you think you have the line:

The quick brown fox jumps over the lazy dog

... but there is a chr$(13) character between 'fox' and 'jumps', then the test button would display the line in two halves:

1. The quick brown fox
2. jumps over the lazy dog

I hope these notes will be helpful.

Bob Stubbs (London, UK)
 
mmsu,

I'll confirm what Bob is saying. I did something similar, creating a test file 32768 characters long then reading that using Line Input and checking the length of the returned string: 32768.


Regards,
Mike
 
Thanks a lot guys!!!

I did not noticed that chr$(13) there.

Thanks a lot again.. This really helps me a lot.

BR,

Arnold
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top