0

:( can any one tell me how to write the errors/exceptions, occured while compiling vb.net program, in a text file?????????
IN VB.NET2003
:'(

4
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by cutepinkbunnies
0

Why do you need this??? And can't you copy/paste the output from Visual Studio to a text file manually???

0

I don't have or know vb 2003 but use the Try Catch. Under the catch send the error to your log file.
Try this:

Imports System.IO

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim x, y As Integer
        y = 0
        Try
            x = 5 / y
        Catch ex As Exception
            Dim writer As New StreamWriter("C:\MyLog.log", True, System.Text.Encoding.ASCII)
            writer.WriteLine(ex.Message)
            writer.Close()
        End Try

    End Sub

End Class
0

There is also a way you can write the exceptions to your Event Logs if that comes in handy.

If you're trying to use this to debug, you might want to use something like.

Try
blah
Catch ex as Exception
Messagebox.show(ex.tostring)
End Try

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.