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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
| Private Sub BGW_RunWorkerCompleted(sender As Object, e As RunWorkerCompletedEventArgs) Handles BGW.RunWorkerCompleted
If e.Cancelled = True Then
MsgBox("Canceled!")
ElseIf e.Error IsNot Nothing Then
MsgBox("Error: " & e.Error.Message)
Else
MsgBox("Done!")
End If
End Sub
Private Sub BackgroundWorker1_DoWork(sender As Object, e As DoWorkEventArgs) Handles BGW.DoWork
soldDJEZZY()
End Sub
Private Sub BGW_ProgressChanged(sender As Object, e As ProgressChangedEventArgs) Handles BGW.ProgressChanged
TextBox5.Text = e.UserState.ToString
End Sub
'buton solde djezzy
Private Sub Button26_Click(sender As Object, e As EventArgs) Handles Button26.Click
If Not BGW.IsBusy Then BGW.RunWorkerAsync()
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
End Sub
Sub soldDJEZZY()
' 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
BGW.ReportProgress(0, strResponse)
MsgBox(strResponse)
UpdateResult2(objGsm.LastError)
objGsm.Close()
'Cursor = Cursors.Default
End Sub |
Partager