Click here to Skip to main content
16,016,463 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Showing webpages Pin
Dave Kreskowiak28-Sep-07 9:21
mveDave Kreskowiak28-Sep-07 9:21 
GeneralRe: Showing webpages Pin
DigiOz Multimedia28-Sep-07 19:20
DigiOz Multimedia28-Sep-07 19:20 
QuestionAccessing controls on startup Form Pin
AliAmjad28-Sep-07 4:21
AliAmjad28-Sep-07 4:21 
AnswerRe: Accessing controls on startup Form Pin
Dave Kreskowiak28-Sep-07 6:10
mveDave Kreskowiak28-Sep-07 6:10 
GeneralRe: Accessing controls on startup Form Pin
AliAmjad29-Sep-07 4:22
AliAmjad29-Sep-07 4:22 
GeneralRe: Accessing controls on startup Form Pin
Dave Kreskowiak29-Sep-07 5:16
mveDave Kreskowiak29-Sep-07 5:16 
GeneralRe: Accessing controls on startup Form Pin
AliAmjad29-Sep-07 7:16
AliAmjad29-Sep-07 7:16 
GeneralRe: Accessing controls on startup Form Pin
Dave Kreskowiak29-Sep-07 8:17
mveDave Kreskowiak29-Sep-07 8:17 
AliAmjad wrote:
How can i append the messages to the Textbox


It's easy. I occasionally use this quick'n'dirty class to do the same thing while I'm writing an app:
Public Class TraceLogSupport
    Inherits TraceListener
 
    Private _targetTextBox As TextBox = Nothing
 
    Public Sub New(ByVal TextBoxControl As TextBox)
        Mybase.New()
        If TextBoxControl IsNot Nothing Then
            _targetTextBox = TextBoxControl
        Else
            MyBase.Dispose()
            Throw New ArgumentNullException("You must specify a TextBox control to use to show log information.")
        End If
    End Sub
 
    Public Overrides Sub Write(ByVal message As String)
        _targetTextBox.AppendText(message)
    End Sub
 
    Public Overrides Sub WriteLine(ByVal message As String)
        Me.Write(message & Environment.NewLine)
    End Sub
End Class

To use it, all you do is creat an instance of it and pass it a TextBox you want it to use to log information to. I usually just use a small form with a TextBox on it and do something like this in it's Load event:
    Private _tractListener As TraceLogSupport
 
...
 
    Private Sub LogForm_Load(blah, blah) Handles MyBase.Load
        _traceListener = New TraceLogSupport(LogTextBox)
        Trace.AutoFlush = True
        Trace.Listeners.Add(_traceListener)
    End Sub

That's it, except for peppering the code with Trace.Write and Trace.WriteLine statements...



A guide to posting questions on CodeProject[^]

Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic
     2006, 2007


GeneralRe: Accessing controls on startup Form Pin
AliAmjad29-Sep-07 11:39
AliAmjad29-Sep-07 11:39 
QuestionCrystal Reports Database Login Problem Pin
Kschuler28-Sep-07 3:58
Kschuler28-Sep-07 3:58 
AnswerRe: Crystal Reports Database Login Problem Pin
Paul Conrad30-Sep-07 13:41
professionalPaul Conrad30-Sep-07 13:41 
GeneralRe: Crystal Reports Database Login Problem Pin
Kschuler1-Oct-07 2:57
Kschuler1-Oct-07 2:57 
QuestionError? Pin
gates0928-Sep-07 2:23
gates0928-Sep-07 2:23 
AnswerRe: Error? Pin
GuyThiebaut28-Sep-07 2:35
professionalGuyThiebaut28-Sep-07 2:35 
GeneralRe: Error? Pin
gates0928-Sep-07 2:45
gates0928-Sep-07 2:45 
AnswerRe: Error? Pin
gates0928-Sep-07 2:47
gates0928-Sep-07 2:47 
QuestionRe: Error? Pin
gates0928-Sep-07 3:11
gates0928-Sep-07 3:11 
AnswerRe: Error? Pin
GuyThiebaut28-Sep-07 4:04
professionalGuyThiebaut28-Sep-07 4:04 
GeneralRe: Error? Pin
gates0928-Sep-07 4:19
gates0928-Sep-07 4:19 
GeneralRe: Error? Pin
GuyThiebaut28-Sep-07 4:22
professionalGuyThiebaut28-Sep-07 4:22 
QuestionOutlook2003 Pin
PeterStaal28-Sep-07 2:21
PeterStaal28-Sep-07 2:21 
AnswerRe: Outlook2003 Pin
Dave Kreskowiak28-Sep-07 6:07
mveDave Kreskowiak28-Sep-07 6:07 
QuestionPass Value in Crystal Report Pin
TeJAs.....28-Sep-07 2:11
TeJAs.....28-Sep-07 2:11 
AnswerRe: Pass Value in Crystal Report Pin
DigiOz Multimedia28-Sep-07 8:50
DigiOz Multimedia28-Sep-07 8:50 
QuestionConnecting to ADO.NET Pin
ashwinibhalerao28-Sep-07 1:47
ashwinibhalerao28-Sep-07 1:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.