I want to show the error occured, date, error description in a text file.
Following is vb code. Can any one tell me how to write it in vb.net????

Open App.Path & "\ErrorLog" & Replace(Date, "/", "_") & ".txt" For Append As #1
Write #1, "Error in News update Exe:- Form Load Function ---" & Err.Description & "---" & Time
Write #1, "--------------------------------"
Close #1


Re: vb to vb.net 80 80

Learn how to:-

-Open a file for writing
-Write to a file
-Use string.replace to replace "/" with "_"
-Close the file

Re: vb to vb.net 80 80

It appears that you want to use vb6 code in a Try:Catch block. You do need to learn the things stated above but 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
            x = 25 / y
        Catch ex As Exception
            Dim filename As String = My.Application.Info.DirectoryPath & "\ErrorLog" & Now.ToShortDateString.Replace("/", "_") & ".txt"
            Dim sw As StreamWriter = New StreamWriter(filename, True)
            sw.WriteLine("Error in News update Exe:- Form Load Function ---" & Err.Description & "---" & Now.ToLocalTime)

        End Try

    End Sub
End Class
Be a part of the DaniWeb community

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