Newsgroup: it.comp.lang.visual-basic
Titolo: Problemi con modem USB

Ciao a tutti...
Ho scritto una piccola applicazione in visual basic per riconoscere il
numero del chiamante attraverso un modem...
Qualcuno mi sa spiegare perche' con il codice seguente funziona tutto bene
con un modem interno o seriale, ma non funziona con i modem USB?????
Grazie a tutti,
Claudia
Option Explicit
Public bOK                     As Boolean
Public bRing                   As Boolean
Public bError                  As Boolean
Public iRingTime               As Single
Private Sub Form_Load()
    'retrieve last port settings
    Comm1.Settings = ""
    Comm1.CommPort = "3"
    Comm1.Handshaking = ""
    Comm1.PortOpen = True
    Comm1.DTREnable = True
    Comm1.RTSEnable = True
    Comm1.RThreshold = 1                                    ' Generate a
receive event on every character received
    Comm1.InputLen = 1                                      ' Read the
receive buffer 1 char at a time
    bOK = False
    bError = False
    Comm1.Output = vbCr & "ATZ" + vbCr                      ' Send command
to put Identifier in event mode and receive serial number
    Wait
    If bOK Then
      bOK = False
      bError = False
      Comm1.Output = "AT#CID=1" + vbCr                        'Turn on
caller id events
      Wait
      If bError Then
        MsgBox "Port " & Comm1.CommPort & ": Modem not Caller ID enabled"
        Comm1.PortOpen = False                                  ' Close the
port and update app UI
        Connect.Caption = "&Connetti"                            ' Change
the menu to reflect opposite of port status
      ElseIf bOK Then
        Connect.Caption = "Dis&connetti"                         ' Change
the menu to reflect opposite of port status
      End If
    Else
      MsgBox "Port " + Str(Comm1.CommPort) + " not responding"
      Comm1.DTREnable = False
      Comm1.RTSEnable = False
      Comm1.PortOpen = False                                  ' Close the
port and update app UI
      Connect.Caption = "&Connetti"                            ' Change the
menu to reflect opposite of port status
    End If
End Sub
Private Sub Wait()
Dim Start
   Start = Timer
   Do While Timer < Start + 2
      DoEvents
      If bOK Then
        Exit Sub
      End If
      If bError Then
        Exit Sub
      End If
   Loop
End Sub
Private Sub ProcessEvent(stEvent As String)
  Dim stNumber As String
       ModemEvents.AddItem stEvent                            'Add Modem
event to event listbox
        Select Case stEvent
           Case "OK"
             bOK = True
           Case "ERROR"
             bError = True
           Case "RING"
             If bRing = False Then
               frmPrincipale.DateTime.Text = Now
               bRing = True
             End If
             iRingTime = Timer
           Case Else
             Select Case Left(stEvent, 4)
               Case "TIME"
               Case "DATE"
               Case "NMBR"
                 stNumber = Mid(stEvent, 8)
                 frmPrincipale.Number.Text = stNumber
                 AddRecord
               Case "NAME"
             End Select
        End Select
End Sub
Private Sub comm1_OnComm()
    Static stEvent             As String                       'storage for
an Modem event
    Dim stComChar               As String * 1                   'temporary
storage for received comm port data
    If Comm1.CommEvent = comEvReceive Then
            Do
                stComChar = Comm1.Input
                Select Case stComChar
                    Case vbLf
                    Case vbCr
                        If Len(stEvent) > 0 Then
                          ProcessEvent stEvent
                          stEvent = ""
                        End If
                    Case Else
                        stEvent = stEvent + stComChar
                End Select
            Loop While Comm1.InBufferCount
    End If
End Sub

 USB????? Grazie a tutti,
Direi perchč usi l'oggetto MSCOM che comanda la porta com e non la usb...
-- 
Alex
"Un uomo saggio impara dall'esperienza,
un uomo ancora piů saggio impara dall'esperienza degli altri." (Saggio
Cinese)