Debug Status : Debug « Development « VB.Net Tutorial

Home
VB.Net Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statements
5.Date Time
6.Class Module
7.Development
8.Collections
9.Generics
10.Attributes
11.Event
12.LINQ
13.Stream File
14.GUI
15.GUI Applications
16.Windows Presentation Foundation
17.2D Graphics
18.I18N Internationlization
19.Reflection
20.Regular Expressions
21.Security
22.Socket Network
23.Thread
24.Windows
25.XML
26.Database ADO.net
27.Design Patterns
VB.Net
VB.Net by API
VB.Net Tutorial » Development » Debug 
7.20.2.Debug Status
Imports System.Diagnostics
Imports System.IO
Module Module1
    Sub Main()
        Dim Str As FileStream
        Dim Listener As TextWriterTraceListener

        If (Debugger.IsAttachedThen
            Console.WriteLine("Debugging")

            Str = New FileStream("C:\DebugMessages.txt", System.IO.FileMode.Append)
            Dim DebugFile As New StreamWriter(Str)
            Listener = New TextWriterTraceListener(DebugFile)
            Debug.Listeners.Add(Listener)
            Debug.AutoFlush = True
        Else
            Console.WriteLine("Not debugging")
        End If


        Debug.WriteLine("")
        Debug.WriteLine("Messages generated at " & Now())
        Debug.WriteLine("In Button Click")
        Debug.WriteLine("Calling First")
        First()
        Debug.WriteLine("Exiting Button Click")

        If (Debugger.IsAttachedThen
            Debug.Listeners.Remove(Listener)
            Str.Close()
            Console.WriteLine("Done")
        End If
    
    End Sub
    Private Sub First()
        Debug.WriteLine("In First")
        Debug.WriteLine("Calling Second")
        Second()
        Debug.WriteLine("Back in First")
    End Sub

    Private Sub Second()
        Debug.WriteLine("In Second")
    End Sub

End Module
Not debugging
7.20.Debug
7.20.1.Convert Debug message to a file
7.20.2.Debug Status
7.20.3.Use Debug.Assert
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.