1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| Private Sub solde()
strCommand = String.Format("AT+CUSD=1," & Chr(34) & "{0}" & Chr(34) & ",15", "*" & "710" & "#")
Dim strName As String = cbxDevices.Text
Dim iDeviceSpeed As Integer
If (Not Integer.TryParse(cbxDeviceSpeed.Text, iDeviceSpeed)) Then
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
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
UpdateResult(objGsm.LastError)
Return
End If
If (strResponse.Contains("+CUSD:")) Then
strFields = strResponse.Split(Char.Parse(Chr(34)))
If (strFields.Length > 1) Then
strResponse = strFields(0)
Else
strResponse = strFields(1)
End If
End If
End If
End If
TextBox5.Text = strResponse
UpdateResult(objGsm.LastError)
objGsm.Close()
End Sub
Private Sub BGW_DoWork(sender As Object, e As DoWorkEventArgs) Handles BGW.DoWork
solde()
End Sub
Private Sub BGW_RunWorkerCompleted(sender As Object, e As RunWorkerCompletedEventArgs) Handles BGW.RunWorkerCompleted
MsgBox("Mission complete")
End Sub |
Partager