sengreen 0 Newbie Poster

Hi everyone. I am making aproject in vb6 with MScomm. Computer A connected with a device on serial port. I can receive the data from serial port in a text box. Computer A can also dial cmputer B to make connection. But it is unable to send data on modem or computer B is unable to receive data from modem.
Here is the code for sending and receiving computers
1- Computer A

Option Explicit
'button to open data port to receive from device
Private Sub cmdOpen_Click()
    On Error Resume Next
    If MSComm2.PortOpen = False Then
      MSComm2.PortOpen = True
      If Err = 8005 Then
        Err.Clear
        MsgBox "Com Port " & MSComm2.CommPort & " Failed to open", vbCritical, "Serial Data Logger"
      End If
      Exit Sub
    End If
End Sub
'Button to dial
Private Sub Dial_Click()
    On Error Resume Next
    If MSComm1.PortOpen = False Then
      MSComm1.PortOpen = True
      If Err = 8012 Then
        Err.Clear
        MsgBox "Com Port " & MSComm1.CommPort & " Failed to open", vbCritical, "Serial Data Logger"
      End If
      Exit Sub
    End If
    
    'MSComm1.Output = "AT&F0" & vbCrLf
    'MSComm1.Output = "+++"
    MSComm1.Output = "ATDT 12345" & vbCrLf
    'OutputBox.Text = "Dialing 12345"
    ' Wait for the carrier detect signal, which
    ' indicates that the modem is connected.
    Do Until MSComm1.CDHolding
      'OutputBox.Text = OutputBox.Text & "."
      OutputBox.Text = "."
      DoEvents
    Loop
End Sub
'On loading of form
Private Sub Form_Load()
    'Modem Port
    MSComm1.CommPort = 3
    MSComm1.Settings = "9600,n,8,1"
    MSComm1.RTSEnable = True
    'MSComm1.DTSEnable = True
    MSComm1.RThreshold = 1
    MSComm1.SThreshold = 1
    MSComm1.Handshaking = comNone
    MSComm1.PortOpen = True
    'Open "C:\data.txt" For Output As #1
    'Data port for receiving data from attached device
    MSComm2.CommPort = 10
    MSComm2.Settings = "9600,n,8,1"
    MSComm2.RTSEnable = True
    'MSComm1.DTSEnable = True
    MSComm2.RThreshold = 1
    MSComm2.SThreshold = 1
    MSComm2.Handshaking = comNone
    If MSComm2.PortOpen = True Then
      MSComm2.PortOpen = False
    End If

End Sub
'Button to hangup
Private Sub HangUp_Click()
    If MSComm1.PortOpen = True Then
        MSComm1.Output = "+++"
        MSComm1.Output = "ATH0"
        MSComm1.PortOpen = False
        OutputBox.Text = "HANG UP."
    Else
        MsgBox "Port is already closed", vbCritical, "Serial Data Logger"
    End If
End Sub
'Modem Port Events
Private Sub MSComm1_OnComm()
    Select Case MSComm1.CommEvent
        ' Capture any incoming data and write it to the output box.
        Case comEvSend
            OutputBox.Text = MSComm1.Input
        ' Capture changes in the carrier detect line.
        ' This will detect if the modem has been disconnected.
        Case comEvCD
            If Not MSComm1.CDHolding Then
                HangUp_Click
                OutputBox.Text = OutputBox.Text & "Disconnected."
            End If
    End Select
End Sub
'unload form
Private Sub Form_Unload(Cancel As Integer)
    If MSComm1.PortOpen = True Then
        MSComm1.PortOpen = False
    Exit Sub
    'Close #1
    End If
End Sub
'data port events
Private Sub MSComm2_OnComm()
    Dim EVMsg$
    Dim ERMsg$
    Select Case MSComm2.CommEvent
        Case comEvReceive
            Dim strReceived As Variant
            strReceived = MSComm2.Input
            'strRecieved = Replace(strRecieved, vbCrLf, "")
            Text1.Text = Text1.Text & strReceived
            If MSComm1.PortOpen = True Then
                'MSComm1.Output = Text1.Text & vbCrLf
                OutputBox.Text = Text1.Text & vbCrLf
            End If
            'Print #1, strReceived
            'Print #1, strReceived & vbCrLf
        Case comEvSend
        
        Case comEvCTS
            EVMsg$ = "Change in CTS Detected"
        Case comEvDSR
            EVMsg$ = "Change in DSR Detected"
        Case comEvCD
            EVMsg$ = "Change in CD Detected"
        Case comEvRing
            EVMsg$ = "The Phone is Ringing"
        Case comEvEOF
            EVMsg$ = "End of File Detected"
        ' Error messages.
        Case comBreak
            ERMsg$ = "Break Received"
        Case comCDTO
            ERMsg$ = "Carrier Detect Timeout"
        Case comCTSTO
            ERMsg$ = "CTS Timeout"
        Case comDCB
            ERMsg$ = "Error retrieving DCB"
        Case comDSRTO
            ERMsg$ = "DSR Timeout"
        Case comFrame
            ERMsg$ = "Framing Error"
        Case comOverrun
            ERMsg$ = "Overrun Error"
        Case comRxOver
            ERMsg$ = "Receive Buffer Overflow"
        Case comRxParity
            ERMsg$ = "Parity Error"
        Case comTxFull
            ERMsg$ = "Transmit Buffer Full"
        Case Else
            ERMsg$ = "Unknown error or event"
    End Select
End Sub

2- Computer B

Option Explicit
'close the modem port
Private Sub Close_Click()
    If MSComm1.PortOpen = True Then
        MSComm1.PortOpen = False
    Else
        MsgBox "Port is already closed", vbCritical, "Serial Data Logger"
    End If
End Sub
'open modem port
Private Sub cmdOpen_Click(Index As Integer)
    If MSComm1.PortOpen = False Then
        MSComm1.PortOpen = True
    Else
        MsgBox "Port is already open", vbCritical, "Serial Data Logger"
    End If
End Sub
'loading form
Private Sub Form_Load()
    MSComm1.CommPort = 3
    MSComm1.Settings = "9600,N,8,1"
    MSComm1.RThreshold = 1
    MSComm1.InputLen = 0
    MSComm1.PortOpen = True
    MSComm1.SThreshold = 1
    Open "C:\MyData1.txt" For Output As #1
End Sub
'unloading form
Private Sub Form_Unload(Cancel As Integer)
    If MSComm1.PortOpen = True Then
        MSComm1.PortOpen = False
        Close #1
    End If
End Sub
'modem port events
Private Sub MSComm1_OnComm()
    Select Case MSComm1.CommEvent
        Case comEvReceive
            Dim strReceived As String
            'strReceived = ""
            MSComm1.Output = "ATA3" & Ch$(13)
            strReceived = MSComm1.Input
            'strReceived = Replace(strReceived, vbCrLf, "")
            Text1.Text = Text1.Text & strReceived
            Print #1, strReceived
    End Select
End Sub

I am really stuck at this point. I need some assistence. I want to do it as early as possible. Plz

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.