Which control is good for display log messages?
Something like a textbox, it should automatically scorll up when I add new message line at the bottom, and discard the old message on the top.
Printable View
Which control is good for display log messages?
Something like a textbox, it should automatically scorll up when I add new message line at the bottom, and discard the old message on the top.
I don't quite understand the question.
Just use a ListBox, and when you add something to the end, delete the first one after a set number of items.
And if you want to keep these log messages all the time (change Output to Append):
Code:Public Sub List_Save(TheList As Listbox, FileName As String)
On Error Resume Next
Dim Save As Long
Dim fFile As Integer
fFile = FreeFile
Open FileName For Output As fFile
For Save = 0 To TheList.ListCount - 1
Print #fFile, TheList.List(Save)
Next Save
Close fFile
End Sub
Call List_Save(List1, App.path & "\msg.log")
Public Sub List_Load(TheList As ListBox, FileName As String)
On Error Resume Next
Dim TheContents As String
Dim fFile As Integer
fFile = FreeFile
Open FileName For Input As fFile
Do
Line Input #fFile, TheContents$
Call List_Add(TheList, TheContents$)
Loop Until EOF(fFile)
Close fFile
End Sub
Call List_Load(List1, App.path & "\msg.log")
Public Sub List_Add(List As ListBox, txt As String)
List.AddItem txt
End Sub
That's what I need. Thanks parksieQuote:
Originally posted by parksie
Just use a ListBox, and when you add something to the end, delete the first one after a set number of items.
Although Matthew's method is pretty good for a lot of situations.