dan_g8 Posted January 27, 2015 Share Posted January 27, 2015 Hi, as above really, i have written the below code which ignores some of the blank lines lines starting with a * but not all of them. can anyone see whats wrong with my code, it only ignores about half of the items?? Dim FILE_NAME As String = "C:\test.dat" Dim RES As Boolean Dim TextLine() As String Dim i As VariantType Dim TEMPLINE As String i = 0 If System.IO.File.Exists(FILE_NAME) = True Then Dim objReader As New System.IO.StreamReader(FILE_NAME) Do While objReader.Peek() <> -1 TEMPLINE = objReader.ReadLine() Dim length As Integer = TEMPLINE.Length RES = TEMPLINE.StartsWith(Chr(42)) If (CStr(RES)) = False Then i = i + 2 ReDim Preserve TextLine(0 To i) TextLine(i) = objReader.ReadLine() MsgBox(TextLine(i)) 'End If End If Loop Else MsgBox("File Does Not Exist") End If Quote Link to comment Share on other sites More sharing options...
dan_g8 Posted January 27, 2015 Author Share Posted January 27, 2015 forgot to say vb.net visual studio 2010 Quote Link to comment Share on other sites More sharing options...
BlackBox Posted January 27, 2015 Share Posted January 27, 2015 forgot to say vb.net visual studio 2010 Thank you! can anyone see whats wrong with my code, it only ignores about half of the items?? Well... It is not written in C#. *kidding* In all seriousness, can you post a sample .DAT file for us to test? Cheers Quote Link to comment Share on other sites More sharing options...
Tyke Posted January 28, 2015 Share Posted January 28, 2015 Like BB said a sample DAT file would be most helpful. I had a similar problem a good while ago and the problem turned out to be the DAT not the code. I was getting the DAT from a third party piece of software and for some reason it was sometimes putting a space at the beginning of just some lines which was causing me all kind of problems. A simple TRIM function on the input string sorted it all out. Have you tried using ("*") instead of (Chr(42)) Ben Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.