Imports System.Net Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click Form2.Show() Form2.Timer1.Start() Form2.animated.Visible = True End Sub Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork Dim MAJ As New WebClient Dim DernièreVersion As String = MAJ.DownloadString("https://dl.dropboxusercontent.com/s/pwaph79vw8v8sfx/Version.txt") invisible.Text = DernièreVersion End Sub Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted If VersionActuelle = invisible.Text Then Form2.MAJexist.Text = "Aucune mise à jour disponible" Form2.ok.Visible = True Else Form2.MAJexist.Text = "Une mise à jour est disponible" Form2.download.Visible = True Form2.cancel.Visible = True End If End Sub End Class
Imports System.Net Public Class Form8 Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick animated.Text = animated.Text + "." If animated.Text = "Veuillez patienter...." Then animated.Text = "Veuillez patienter." End If End Sub Private Sub ok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ok.Click Me.Hide() End Sub Private Sub cancel_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cancel.Click Me.Hide() End Sub Private Sub download_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles download.Click Dim MAJDownload As New WebClient Dim DownloadLink As String = MAJDownload.DownloadString("https://dl.dropboxusercontent.com/s/s0uj4t9wcittto5/Download.txt") Process.Start(DownloadLink) End Sub End Class
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question#Region "Thread"
'pour lancer le thread
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdcreer.Click
BackgroundWorker1.RunWorkerAsync()
End Sub
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
Dim MyThread As BackgroundWorker = CType(sender, BackgroundWorker) 'récupération du thread d'arrière plan
Dim pourcent As Integer
MyThread.ReportProgress(pourcent) 'pourcent est un Integer indiquant l'état d'avancement.
'Ajoute l'opération a effectuée ton code
End Sub
Private Sub BackgroundWorker1_ProgressChanged( _
ByVal sender As Object, _
ByVal e As ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged
Timer1.Start() ' déplacement du texte dans le label
animated.Text = " Veuillez patienter....... " 'label défilant
End Sub
'Quand le code d'arrière plan est terminé la procédure RunWorkerCompleted est exécutée.
Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As Object, _
ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
' ici, elle affiche un message indiquant que le thread d'arrière plan est terminé.
' MessageBox.Show("Opération réussie. ", " Mon Titre", MessageBoxButtons.OK, MessageBoxIcon.Information)
animated.Text = " Opération réussie..... " 'label défilant
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrlabel.Tick
' déplacement du texte dans le label
animated.Text = Mid(animated.Text, 2, animated.Text.Length - 1) & Mid(animated.Text, 1, 1)
End Sub
#End Region
Private WithEvents backgroundWorker1 As New System.ComponentModel.BackgroundWorker
Private Sub backgroundWorker1_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles backgroundWorker1.DoWork
CheckUpdates()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdcreer.Click
timer1.start()
timer1.interval = 1
BackgroundWorker1.RunWorkerAsync()
End Sub
Private Sub Time1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
if label1.visible = true then
label1.visble = false
elseif label1.visible = false then
label1.visible = true
end if
directcast(sender,timer).interval = 800
end sub
Private Sub backgroundWorker1_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles backgroundWorker1.RunWorkerCompleted
timer1.stop()
End Sub
Public Class Accueil
Private Pas As Double = 1000, Nbr As Integer = 10, n As Integer = 1
Private Sub Mar_Click(sender As System.Object, e As System.EventArgs) Handles Mar.Click
Démarrer()
End Sub
Private Sub Arr_Click(sender As Object, e As System.EventArgs) Handles Arr.Click
Arrêter()
End Sub
Public Sub Démarrer()
Tps.Start()
n = 1
End Sub
Public Sub Arrêter()
Tps.Stop()
Masquer()
End Sub
Private Sub Afficher()
Affichage.Show()
Affichage.Aff.Text = "Veuillez patienter" & Cars(".", n)
End Sub
Private Sub Masquer()
Affichage.Close()
End Sub
Private Sub Tps_Tick(sender As Object, e As System.EventArgs) Handles Tps.Tick
Afficher()
If n = Nbr Then n = 1 Else n += 1
End Sub
Private Function Cars(ByVal c As String, n As Integer) As String
Dim Cr As New String(System.Convert.ToChar(c), n)
Cars = Cr
End Function
End Class
Public Class Affichage
End Class