Con questo codice funzione ma se tolgo la chiave usb io vorrei che si bloccasse invece si apre senza problemi, sostanzialmente la procedura funziona solo se trova una chiave usb altrimenti parte senza problemi
Dim Drive As IO.DriveInfo
Dim ChiaveUSB As String
Dim usb As New USB_Serial2
Dim ans As String
For Each Drive In My.Computer.FileSystem.Drives
If Drive.DriveType = IO.DriveType.Removable Then
ChiaveUSB = (Drive.Name.TrimEnd("\"c))
Try
ans = usb.GetSerialNumber(ChiaveUSB)
If ans = "" Then
End
End If
If ChiaveUSB <> "" And ans = "123456789" Then
MsgBox("TROVATA !!")
Else
MsgBox("Chiave di protezione non trovata.")
End
End If
Catch ex As Exception
MsgBox("Chiave di protezione non trovataaaaaa.")
End Try
End If
Next