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

Recommended Answers

All 3 Replies

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

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.