Here's a logging method I wrote in VB .Net a while back, maybe it will help:
Public Function LOG(ByRef info As String) As Object
On Error Resume Next
If Err.Number = 0 Then
FileOpen(1, LOGFILE, OpenMode.Append)
PrintLine(1, TimeOfDay & "-> " & info)
FileClose(1)
End If
End Function