CommEvent won't trigger RRS feed

  • Question

  • Hello,

    I want to communicate with a hardware via serial port. For this I am using a MSCOMM object which it was declared programmatically. My problem is that using CommEvent it will never enter the event handler function. Any solutions?

    Thank you

    Dim Init_OK As Boolean
    Public comObj As MSCommLib.MSComm
    ''Public comObj As Object
    Private receiveData As String

        'INPUT: none
        'OUTPUT: none
        'DESCRIPTION: set the serial communication atributes

    Sub Init_SerialComm()

        Init_OK = False
         ''Set comObj = CreateObject("MSCommLib.MSComm")
        Set comObj = New MSCommLib.MSComm
        With comObj
            .CommPort = 7
            .Settings = "115200,n,8,1"
            .PortOpen = True
            .InputLen = 0
            .RThreshold = 1
            .SThreshold = 1
            .DTREnable = True
        End With
        Init_OK = True
    End Sub

    '-------------------------------------Private Sub comObj_OnComm()

     Select Case comObj.CommEvent
            Case comEvReceive
                receiveData = comObj.Input
               '' RecvData
            Case comEvSend
                Debug.Print "tzatzosenie"
        End Select
    End Sub

    • Moved by George Hua Wednesday, September 10, 2014 6:14 AM Moved from Excel for developers forum
    Tuesday, September 9, 2014 4:23 PM

All replies

  • Hi,

    Welcome to MSDN forum.

    According to your description, I think the issue is more related to MSComm in VBA.

    I have moved this thread to VBA forum for more effective responses.

    Thanks for your understanding.

    In addition, the article below may be helpful for you:

    Visual Basic: MSComm Control



    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, September 10, 2014 6:12 AM
  • How do you call the Event handler Sub?

    Does it need to be in a separate sub? If so you can call it in the Init_SerialComm() by using the Call command.

    Does this help?

    Daniel van den Berg | Washington, USA | "Anticipate the difficult by managing the easy"

    Please vote an answer helpful if they helped. Please mark an answer(s) as an answer when your question is being answered.

    Thursday, September 11, 2014 4:35 PM