Solved

Communication Error

Posted on 1998-06-03
1
226 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month9 days, 22 hours left to enroll

624 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