dadibarca23
Messages postés71Date d'inscriptionmercredi 3 octobre 2012StatutMembreDernière intervention 6 octobre 2019
-
Modifié par NHenry le 10/04/2016 à 14:35
dadibarca23
Messages postés71Date d'inscriptionmercredi 3 octobre 2012StatutMembreDernière intervention 6 octobre 2019
-
10 avril 2016 à 18:01
Bonjour mes amis ,
j'ai un grande problème dans set outil backgroundworker
Imports AxMmCtlLib
Imports System.ComponentModel
Public Class Form1
Dim strResponse As String = ""
Dim strCommand As String = ""
Dim strFields As String()
Dim Counter1 As Integer = 0
Dim objGsm As Gsm = New Gsm
Dim objSmsConstants As SmsConstants = New SmsConstants
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
chercheports()
End Sub
Sub chercheports()
Dim strDevice As String
Dim strPort As String
' Fill devices Combo
cbxDevices.Items.Clear()
' Gets first TAPI device
strDevice = objGsm.FindFirstDevice()
While (objGsm.LastError = 0)
cbxDevices.Items.Add(strDevice)
' Gets next TAPI device.
strDevice = objGsm.FindNextDevice()
End While
' Add COM ports.
' Gets first COM port.
strPort = objGsm.FindFirstPort()
While (objGsm.LastError = 0)
' LESPORT.cbxDevices3.Items.Add(strPort)
cbxDevices.Items.Add(strPort)
'Gets next COM port.
strPort = objGsm.FindNextPort()
End While
If (cbxDevices.Items.Count > 0) Then
'LESPORT.cbxDevices3.SelectedIndex = 0
cbxDevices.SelectedIndex = 0
Else
' Remove previous text from cbx (happens when a user reopens this forms
' and removed all devices and COM ports)
cbxDevices.Text = String.Empty
End If
'Fill deviceSpeed combo
cbxDeviceSpeed.Items.Clear()
cbxDeviceSpeed.Items.Add(objSmsConstants.GSM_BAUDRATE_115200)
cbxDeviceSpeed.SelectedIndex = 0
End Sub
Sub UpdateResult(ByVal nResult As Integer)
TextBox4.Text = (String.Format("{0}: {1}", nResult, objGsm.GetErrorDescription(objGsm.LastError)))
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
BGW.RunWorkerAsync()
End Sub
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
End Class
==================================================mes aucune réponse
merci de mes aidés amis
tchaw
EDIT : Ajout des balises de code (la coloration syntaxique). Explications disponibles ici : ICI
Whismeril
Messages postés18599Date d'inscriptionmardi 11 mars 2003StatutContributeurDernière intervention20 septembre 2023629 10 avril 2016 à 17:50
Bonjour,
wahoo quels progrès! Hier tu ne savais pas utiliser les outils de base de la classe string (split, substring, replace) et en une seule nuit tout ça!
Ha ben non c'est pas possible.....
Prendre à quelqu'un ou sur internet un code bien au delà de son niveau et le bidouiller au hasard ne va pas faire de toi un bon codeur.
Et nous ne sommes pas là pour faire ton boulot à ta place.
Lors de tes précédentes questions, très basiques, tu n'as fait aucun effort pour essayer de trouver par toi même une solution à tes problèmes avec les pistes que nous t'avons données.
Tu as attendu du tout cuit.
Quand tu auras mérité que nous nous repenchions sur ton cas, fais nous signe.
Commence par ce cours débutant, du début à la fin.
Et on verra.