La commande cusd avec gsm vb.net

Contenu du snippet

bonjour a tout le monde
code pour vérifier le solde de gsm attacher avec pc
voila :
Sub soldDJEZZY()

        strCommand = String.Format("AT+CUSD=1," & Chr(34) & "{0}" & Chr(34) & ",15", "*" & parrametre.TextBox9.Text & "#")
        Dim strName As String = parrametre.cbxDevices2.Text()
        Dim iDeviceSpeed As Integer
        If (Not Integer.TryParse(parrametre.cbxDeviceSpeed2.Text, iDeviceSpeed)) Then
            iDeviceSpeed = 0
        End If
        objGsm.Open(strName, "0000", iDeviceSpeed)
        If (objGsm.LastError <> 0) Then
            If (objGsm.LastError = 36103) Then
                MessageBox.Show("Invalid Pin entered: SIM card can be blocked after a number of false attempts in a row.", Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If
        End If

        ' Sends the USSD Command though the selected GSM Modem

        If (objGsm.LastError = 0) Then
            objGsm.SendCommand(strCommand)
        End If

        ' Reads the response from the GSM Modem
        If (objGsm.LastError = 0) Then
            strResponse = objGsm.ReadResponse(10000)
        End If

        If (objGsm.LastError = 0) Then

            If (strResponse.Contains("OK")) Then ' Response should be OK
                objGsm.SendCommand(String.Empty)
                strResponse = objGsm.ReadResponse(10000)

                If (objGsm.LastError <> 0) Then
                    UpdateResult2(objGsm.LastError)
                    Return
                End If

                If (strResponse.Contains("+CUSD:")) Then

                    strFields = strResponse.Split(Char.Parse(Chr(34)))

                    If (strFields.Length > 1) Then
                        strResponse = strFields(1)
                    Else
                        strResponse = strFields(0)
                    End If
                End If
            End If
        End If
        MsgBox(strResponse)
        UpdateResult2(objGsm.LastError)
        objGsm.Close()
        Cursor = Cursors.Default

    End Sub
    

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.