buddyB Posted October 22, 2004 Posted October 22, 2004 Hi, i'm writing a program (in vb.net) which keeps a logfile. This logfile is shown in a Richtextbox. In the richtextbox i want to see the last event(logging) on the first line,then newest data first. I've tried it with SelectionStart and SelectionLength but it wouldn't work. Actually it is easier for me (my program) if i could write a new event on the first line in the logfile instead of the last line.So in stead of the normal writing 1 then 2 then 3 : 1 2 3 i want to this, write 1 then go up a line and write 2, go up again en write 3: 3 2 1 a piece of my program: If File.Exists(FilePath & "LogFile" & DateString & ".bms") FileOpen(2, FilePath & "LogFile" & DateLog & ".bms",OpenMode.Append) 'Open LogFile-file '??????? Goto the first line in the logfile???????? WriteLine(2, PandNaam & " " & LogString) 'write data in the Logfile FileClose(2) 'Close the logfile Else : MsgBox("Can't find LogFile" & DateLog & ".bms.") End If Cheers , BuddyB Quote
Administrators PlausiblyDamp Posted October 22, 2004 Administrators Posted October 22, 2004 Rather than using the legacy VB6 file handling functions you may want to use more of the classes under System.IO. If you create a streamreader based on the file you could just read the entire file into a string array and then use Array.Reverse to put the oldest items at the top. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
buddyB Posted October 25, 2004 Author Posted October 25, 2004 Thank you very much PlausiblyDamp. It works!!! It is very simpel but i didn't think of it. Quote
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.