![]() |
Visual Basic 6 - String Reading
In the following module, the strings are read into an array. But, the Input
statement terminates the string as soon as it encounters a comma instead of reaching upto CRLF. Accordingly, the number of strings is more than actual number of lines. Why? j = 1 Do While Not EOF(1) Input #1, A$ intStrLen = Len(A$) For i = 1 To intStrLen arrIn(j) = Left(A$, 1) j = j + 1 A$ = Right(A$, Len(A$) - 1) Next i arrIn(j) = vbCr arrIn(j + 1) = vbLf j = j + 2 Loop intLen = j |
Visual Basic 6 - String Reading
Why? Because you aren't using Input correctly.
Use Line Input #FileNum, A$ HTH, Bernie MS Excel MVP "V Govindan" wrote in message ... In the following module, the strings are read into an array. But, the Input statement terminates the string as soon as it encounters a comma instead of reaching upto CRLF. Accordingly, the number of strings is more than actual number of lines. Why? j = 1 Do While Not EOF(1) Input #1, A$ intStrLen = Len(A$) For i = 1 To intStrLen arrIn(j) = Left(A$, 1) j = j + 1 A$ = Right(A$, Len(A$) - 1) Next i arrIn(j) = vbCr arrIn(j + 1) = vbLf j = j + 2 Loop intLen = j |
Visual Basic 6 - String Reading
How silly of me! It is really very nice that You took the trouble of
answering. Such help to developers will be very useful. Thank you again. Regards, V Govindan "Bernie Deitrick" wrote: Why? Because you aren't using Input correctly. Use Line Input #FileNum, A$ HTH, Bernie MS Excel MVP "V Govindan" wrote in message ... In the following module, the strings are read into an array. But, the Input statement terminates the string as soon as it encounters a comma instead of reaching upto CRLF. Accordingly, the number of strings is more than actual number of lines. Why? j = 1 Do While Not EOF(1) Input #1, A$ intStrLen = Len(A$) For i = 1 To intStrLen arrIn(j) = Left(A$, 1) j = j + 1 A$ = Right(A$, Len(A$) - 1) Next i arrIn(j) = vbCr arrIn(j + 1) = vbLf j = j + 2 Loop intLen = j |
All times are GMT +1. The time now is 06:23 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com