Solved

Communication Error

Posted on 1998-06-03
1
218 Views
Last Modified: 2010-05-03
I am trying to log all my communication Error messages to the log file.
 ERMsg$ = "Break Received"
            lLogType = vbLogEventTypeError
            sPrintMsg = ERMsg$ & vbCrLf & _
            " Error: [" & Err.Number & "]: " & _
            Err.Description & " Error in: " & Err.Sorce
           
            App.LogPath = "C:\HLRS4.1\Error.log"
            App.StartLogging App.LogPath, vbLogAuto
            App.LogEvent sPrintMsg, lLogType
I created an empty log file on my c drive. But I am getting  error : Can't assign to the read-only property
 App.LogPath = "C:\HLRS4.1\Error.log"
Returns the path and filename of the file used to capture output from the LogEvent method. Not available at design-time; read-only at run time.

From the Help menu:

Syntax

object.LogPath = path

Part      Description
object      An object expression that evaluates to an object                  in the Applies To list.
path      String. The path and filename of a log file.

what changes should i make to my code ? Thank you...


Private Static Sub MSComm1_OnComm()
    Dim EVMsg$
    Dim ERMsg$
    Dim sPrintMsg As String
    Dim lLogType As Long
    ' Branch according to the CommEvent property.
    Select Case MSComm1.CommEvent
        ' Event messages.
        Case comEvReceive
            Dim Buffer As Variant
            Buffer = MSComm1.Input
            Debug.Print "Receive - " & StrConv(Buffer, vbUnicode)
            ShowData txtTerm, (StrConv(Buffer, vbUnicode))
        Case comEvSend
        Case comEvCTS
            EVMsg$ = "Change in CTS Detected"
        Case comEvDSR
            EVMsg$ = "Change in DSR Detected"
        Case comEvCD
            EVMsg$ = "Change in CD Detected"
        Case comEvRing
            EVMsg$ = "The Phone is Ringing"
        Case comEvEOF
            EVMsg$ = "End of File Detected"

        ' Error messages.
        Case comBreak
            ERMsg$ = "Break Received"
            lLogType = vbLogEventTypeError
            sPrintMsg = ERMsg$ & vbCrLf & _
            " Error: [" & Err.Number & "]: " & _
            Err.Description & " Error in: " & Err.Sorce
           
            App.LogPath = "C:\HLRS4.1\Error.log"
            App.StartLogging App.LogPath, vbLogAuto
            App.LogEvent sPrintMsg, lLogType
0
Comment
Question by:gima
1 Comment
 
LVL 1

Accepted Solution

by:
JayMerritt earned 20 total points
ID: 1462398
Try :

'REM App.LogPath = "C:\HLRS4.1\Error.log"
App.StartLogging "C:\HLRS4.1\Error.log", vbLogAuto
App.LogEvent sPrintMsg, lLogType


0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question