Problem calling comEvReceive in NetComm.ocx
-
I have downloaded NetComm.ocx (Active-X control for MSComm control in .NET) and run its sample program successfully. However, I could not call the comEvReceive event when I send a message to my modem using AT commands. Any help or advice is greatly appreciated !! =) Below is my code snippet : Private Sub frmSMS_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load NETComm1.CommPort = 3 NETComm1.set_Settings("115200" & "," & "N" & "," & "7" & "," & "1") NETComm1.Handshaking = NETCommOCX.HandshakeConstants.comNone NETComm1.InputLen = 0 NETComm1.RThreshold = 1 NETComm1.SThreshold = 0 NETComm1.PortOpen = True NETComm1.DTREnable = True MsgBox(NETComm1.CDHolding) MsgBox(NETComm1.CTSHolding) MsgBox(NETComm1.DSRHolding) End Sub Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click Dim strAT, strATTxt, strATSend As String 'Dim busy As Boolean 'strAT = "a" strAT = "AT" & vbCr & vbLf SendMsg(strAT) '-- Select Text Mode 'strATTxt = "AT+CMGF=1" & vbCr 'Call SendMsg(strATTxt) '-- Send Message 'strATSend = "AT+CMGS=96820277" & vbCr 'Call SendMsg(strATSend) 'strATMsg = "Testing from VB" & vbCr 'Call SendMsg(strATMsg) 'busy = True 'Do While busy 'System.Windows.Forms.Application.DoEvents() 'Loop End Sub Private Sub SendMsg(ByRef msg As String) Dim n As Integer If NETComm1.PortOpen Then NETComm1.set_Output(msg) End If End Sub Private Sub NETComm1_OnComm(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NETComm1.OnComm Static EVMsg As String Static ERMsg As String Static Ret As Short '--- Branch according to the CommEvent Prop.. Select Case NETComm1.CommEvent '--- Event messages Case MSCommLib.OnCommConstants.comEvReceive Dim Buffer As VariantType MsgBox(NETComm1.InputData) Buffer = NETComm1.InputData If InStr(Buffer, " OK ") > 0 Then MsgBox(Buffer) End If Case MSCommLib.OnCommConstants.comEvCTS EVMsg = "Change in CTS Detected" Case MSCommLib.OnCommConstants.comE