Solved

Read text file

Posted on 2006-06-10
3
203 Views
Last Modified: 2012-05-05
I need to read the last few lines of a text file that start with today's date and display on a text box. Example, it always start with today's date,  6/10/06(tab)Error log number and error message.
0
Comment
Question by:VBdotnet2005
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
vadim63 earned 500 total points
ID: 16877457
  Private Sub ReadFile()

        Dim sr As New System.IO.StreamReader("C:\test.txt")
        Dim Line As String = sr.ReadLine()
        Dim strToday() As String
        TextBox1.Multiline = True

        Do While Line IsNot Nothing
            strToday = Split(Line, vbTab)
            If strToday(0) = Today Then TextBox1.Text += Line & vbCrLf
            Line = sr.ReadLine()
        Loop

    End Sub
0
 

Author Comment

by:VBdotnet2005
ID: 16877477
Great example. Thank you :)
0
 
LVL 10

Expert Comment

by:vadim63
ID: 16877490
You're welcome.
Cheers.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now