Results 1 to 3 of 3

Thread: OnComm event doesn't fire

  1. #1

    Thread Starter
    Member
    Join Date
    May 2005
    Posts
    59

    OnComm event doesn't fire

    I try to use the code below, and OnComm() doesn't fire

    receiver side :

    Dim MSComm1 As New MSCommlib.MSComm
    Private Sub Form_Load()

    Form1.Caption = "App2"
    With MSComm1
    .Handshaking = 2 - comRTS
    .CommPort = 1
    .RThreshold = 1
    .RTSEnable = True
    .Settings = "9600,n,8,1"
    .SThreshold = 1
    .PortOpen = True
    End With
    Text1.Text = ""
    End Sub

    private sub Form_Unload(Cancel as Integer)
    MSComm1.PortOpen = False
    end Sub

    private sub MSComm1_OnComm()
    MsgBox "some comm event has arrived"
    select case MSComm1.CommEvent
    case .......
    case ....
    end select
    end sub

    sender side:

    Dim MSComm1 As New MSCommlib.MSComm
    Private Sub UserForm_Initialize()

    Form1.Caption = "App1"
    With MSComm1
    .Handshaking = 2 - comRTS
    .CommPort = 1
    .RThreshold = 1
    .RTSEnable = True
    .Settings = "9600,n,8,1"
    .SThreshold = 1
    .PortOpen = True
    End With
    CommandButton1.Caption = "&Send"
    TextBox1.Text = "Test string from App1 "
    End Sub

    Private Sub CommandButton1_Click()
    MSComm1.Output = TextBox1.Text
    End Sub


    Could you plz tell me what am i doing wrong....
    the connection is ok. in case in receiver side i call myself the OnComm Sub the data transfers.

    10x in advance

  2. #2

    Thread Starter
    Member
    Join Date
    May 2005
    Posts
    59

    Re: OnComm event doesn't fire

    i solved the problem...

    I don't think that anyone has the same problem, but ...

    the problem was in the first line : Dim MSComm1 As New MSCommlib.MSComm
    the correct line is : Public WithEvents MSComm1 As MSCommlib.MSComm

    and than inside the sub add the line : Set MSComm1 = CreateObject("MSCommlib.MScomm")

  3. #3
    New Member infohpreet's Avatar
    Join Date
    Apr 2007
    Location
    INDIA
    Posts
    1

    Re: OnComm event doesn't fire

    In order for the OnComm event to fire, you need to set RThreshold and SThreshold to 1.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width