能,用mscomm 控件,看一下MSDN就可以写出来.

解决方案 »

  1.   

    可以的,一个是用MSCOMM控件,另外一个是自己用C++写DLL了,这样的复杂,但是可控制性比较好,我没有写过(准确的说是没有写成功,C++的功夫太差了)
      

  2.   

    有很多书介绍的,你找找。不过大部分都是用MSCOM32的。我也只会用COM32
      

  3.   

    用mscomm,我有一个生产监控系统源程序,有意与我联系 [email protected]
      

  4.   

    Private Sub mnuDial_Click()
        On Local Error Resume Next
        Static Num As String
        
        Num = "1-206-936-6735" ' This is the MSDN phone number
        
        ' Get a number from the user.
        Num = InputBox$("Enter Phone Number:", "Dial Number", Num)
        If Num = "" Then Exit Sub
        
        ' Open the port if it isn't already open.
        If Not MSComm1.PortOpen Then
           mnuOpen_Click
           If Err Then Exit Sub
        End If
          
        ' Enable hang up button and menu item
        mnuHangUp.Enabled = True
        tbrToolBar.Buttons("HangUpPhone").Enabled = True
                  
        ' Dial the number.
        MSComm1.Output = "ATDT" & Num & vbCrLf
        
        ' Start the port timer
        StartTiming
    End Sub
      

  5.   

    ' The OnComm event is used for trapping communications events and errors.
    Private Static Sub MSComm1_OnComm()
        Dim EVMsg$
        Dim ERMsg$
        
        ' Branch according to the CommEvent property.
        Select Case MSComm1.CommEvent
            ' Event messages.
            Case comEvReceive
                Dim Buffer As Variant
                Buffer = MSComm1.Input
                Debug.Print "Receive - " & StrConv(Buffer, vbUnicode)
                ShowData txtTerm, (StrConv(Buffer, vbUnicode))
            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
        
        If Len(EVMsg$) Then
            ' Display event messages in the status bar.
            sbrStatus.Panels("Status").Text = "Status: " & EVMsg$
                    
            ' Enable timer so that the message in the status bar
            ' is cleared after 2 seconds
            Timer2.Enabled = True
            
        ElseIf Len(ERMsg$) Then
            ' Display event messages in the status bar.
            sbrStatus.Panels("Status").Text = "Status: " & ERMsg$
            
            ' Display error messages in an alert message box.
            Beep
            Ret = MsgBox(ERMsg$, 1, "Click Cancel to quit, OK to ignore.")
            
            ' If the user clicks Cancel (2)...
            If Ret = 2 Then
                MSComm1.PortOpen = False    ' Close the port and quit.
            End If
            
            ' Enable timer so that the message in the status bar
            ' is cleared after 2 seconds
            Timer2.Enabled = True
        End If
    End Sub
      

  6.   

    当然可以了,用MSCOMM控件,设置端口号等属性,就可以进行通讯了
      

  7.   

    请看vb自带的 Mscomm 文件夹里面的内容
      

  8.   

    请看vb自带的 Mscomm 文件夹里面的内容
      

  9.   

    用Mscomm控件:
    设置波特率、串行口
    用Input属性接收数据