mscomm32 in vb.net 2002

thespazz84

New member
Joined
Nov 30, 2003
Messages
2
Location
Minneapolis, MN
Hello.
Im working on a project that uses a hardware mpeg2 card to play an mpeg file when it recieved a contact closure on the serial ports CD line. One of my coworkers has used this method in the past in VB6 and I am having a hard time porting it to .net. here is snippets of my source code:
Code:
    Dim ComEvCD As MSCommLib.CommEventConstants

   Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        MSComm.CommPort = 1
        MSComm.PortOpen = True
        MSComm.DTREnable = True
 End Sub

    Private Sub axMScomm1_OnComm(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MSComm.OnComm
   Select Case MSComm.CommEvent
            Case ComEvCD   Change in the CD line.
                If MSComm.CDHolding = True Then
                mpgPlay(0, 0)
                MessageBox.Show("CD closed", "mscomm32", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
                End If
... more select case statements as needed
end select
end sub

It dosnt give me any errors, but it dosnt work. what am i doing wrong
thanks
-Brandon McKenzie
 
I got it figured out, VB.net dosnt have teh constants defines, i had to use teh numerical values that commevent returns

Code:
    Private Sub MScomm_OnComm(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MSComm.OnComm
        Select Case MSComm.CommEvent  more information at bottom of file
            Case 3   Change in the CTS line. plays channel 1
                If MSComm.CTSHolding = True Then
                    CTStimer.Enabled = True
                End If
            Case 5 change in the CD line  plays channel 2
                If MSComm.CDHolding = True Then
                    CDtimer.Enabled = True
                End If
            Case Else
                problem = "An unknown event occured on Com port 1"
                Call writelog(problem)
        End Select
    End Sub

the times debounce the inputs so that we dont keep restarting the file over and over.
-Brandon McKenzie
 
Back
Top