Hi everyone. I am trying to use MScomm in vb6 throught Modem. There are two computers , both are connected through dial up modem. I want to send a file from first computer to the other. First Computer dials second computer to make connection. I am able to get a ring message on the second computer .But it is unable to send data on modem or second computer is unable to receive data from modem.
Here is the code for sending and receiving computers
first computer
Private Sub Command1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Dial.Click
Dim Number$, Temp$
Dim DialString$
Dim Status As String
Dim FileName, OutBuff As String
Text1.Text = "Test string from App1 "
Number$ = InputBox$("Enter phone number:", "Number$")
If Number$ = "" Then Exit Sub
Dim T As Single
Dim TimeoutVal As Single
Temp$ = Status
Status = "Dialing - " + Number$
DialString$ = "ATDT" + Number$ + ";" + vbCr
On Error Resume Next
If MSComm1.PortOpen = False Then
MSComm1.CommPort = 4
MSComm1.Settings = "9600,N,8,1"
MSComm1.PortOpen = True
MSComm1.RThreshold = 1
MSComm1.RTSEnable = True
MSComm1.SThreshold = 1
End If
MSComm1.Output = DialString$
Do
' System.Windows.Forms.Application.DoEvents()
Temp$ = Temp$ & MSComm1.Input
If InStr(Temp$, "NO DIALTONE" & vbCrLf) Then
End
End If
Loop Until InStr(Temp$, "OK" & vbCrLf)
I am getting an error "CTL_E_GETNOTSUPPORTED" at the last line..
In second computer, i am getting a ring, but after that nothing is happening. Code is shown below
If MSComm1.PortOpen = False Then
MSComm1.CommPort = 6
MSComm1.Settings = "9600,N,8,1"
MSComm1.RThreshold = 1
MSComm1.RTSEnable = True
MSComm1.SThreshold = 1
MSComm1.InputLen = 0
MSComm1.InputMode = InputModeConstants.comInputModeText
MSComm1.PortOpen = True
MSComm1.DTREnable = True
MSComm1.Output = "ATS0=1" & vbCrLf
Else
MsgBox("Port is already open" & MSComm1.CommPort & "Port", vbCritical, "Serial Data Logger")
End If
Code:
private Sub MSComm1_OnComm(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MSComm1.OnComm
Dim ErrMsg As Object
Dim InBuff As String
Select Case MSComm1.CommEvent
' Handle each event or error by placing
' code below each case statement
' Errors
Case MSCommLib.CommEventConstants.comEventBreak ' A Break was received.
ErrMsg = "Break"
' These next three timeout values are no longer detected in Win32
Case MSCommLib.CommEventConstants.comEventCDTO ' CD (RLSD) Timeout.
Case MSCommLib.CommEventConstants.comEventCTSTO ' CTS Timeout.``
Case MSCommLib.CommEventConstants.comEventDSRTO ' DSR Timeout.
Case MSCommLib.CommEventConstants.comEventFrame ' Framing Error
ErrMsg = "Framing"
Case MSCommLib.CommEventConstants.comEventOverrun ' Data Lost.
ErrMsg = "Overrun"
Case MSCommLib.CommEventConstants.comEventRxOver ' Receive buffer overflow.
ErrMsg = "OverFlow"
)
Case MSCommLib.CommEventConstants.comEventRxParity ' Parity Error.
ErrMsg = "Parity"
Case MSCommLib.CommEventConstants.comEventTxFull ' Transmit buffer full.
ErrMsg = "TX Full"
Case MSCommLib.CommEventConstants.comEventDCB ' Unexpected error retrieving DCB]
ErrMsg = "DBC"
' Events
Case MSCommLib.OnCommConstants.comEvCD ' Change in the CD line.
If MSComm1.CDHolding = True Then
Connected = True
Else
Connected = False
End If
Case MSCommLib.OnCommConstants.comEvCTS ' Change in the CTS line.
Case MSCommLib.OnCommConstants.comEvDSR ' Change in the DSR line.
ErrMsg = "comEvDSR"
Call handleinbuff(ErrMsg)
Case MSCommLib.OnCommConstants.comEvRing ' Change in the Ring Indicator.
Case MSCommLib.OnCommConstants.comEvReceive ' Received RThreshold # of chars.
Dim strreceive As VariantType
InBuff = MSComm1.Input
Call handleinbuff(InBuff)
Case MSCommLib.OnCommConstants.comEvSend ' There are SThreshold number of
' characters in the transmit buffer.
Do While MSComm1.OutBufferCount > 0
System.Windows.Forms.Application.DoEvents()
Loop
Case MSCommLib.OnCommConstants.comEvEOF ' An EOF character was found in ' the input stream
End Select
End Sub
Sub handleinbuff(ByVal inbuff As String)
Text1.SelectionStart = Len(Text1.Text)
Text1.Text = inbuff
End Sub
I am still confused whether the problem is in first computers code or the second computers code .. Please help
Also i am getting continuous event on MSCOMM1_onevent , Case MSCommLib.OnCommConstants.comEvSend in the dialing computer. But i am not writing anything to the mscomm1.output other than the phone number which has to be dialled. Because of this an exception is coming ( CTL_E_GETNOTSUPPORTED)