Derniers messages sur Zeste de Savoirhttps://zestedesavoir.com/forums/2018-08-31T18:51:37+02:00Les derniers messages parus sur le forum de Zeste de Savoir.Erreur While, Do Loop, ... [VB.NET], message #1879042018-08-31T18:51:37+02:00LeGeek57510/@LeGeek57510https://zestedesavoir.com/forums/sujet/11222/erreur-while-do-loop-vbnet/?page=1#p187904<p>Finalement j’ai réussi, il a juste fallut vérifier si le Invoke était requis.</p>Erreur While, Do Loop, ... [VB.NET], message #1877902018-08-30T21:09:47+02:00LeGeek57510/@LeGeek57510https://zestedesavoir.com/forums/sujet/11222/erreur-while-do-loop-vbnet/?page=1#p187790<p>Une solution ? Merci</p>Erreur Thread [VB.NET], message #1875472018-08-29T12:50:23+02:00LeGeek57510/@LeGeek57510https://zestedesavoir.com/forums/sujet/11207/erreur-thread-vbnet/?page=2#p187547<p>Très bien,</p>
<div class="hljs-code-div"><div class="hljs-line-numbers"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></div><pre><code class="hljs language-vbnet"><span class="hljs-keyword">Private</span> <span class="hljs-keyword">Sub</span> Button1_Click(<span class="hljs-keyword">ByVal</span> sender <span class="hljs-keyword">As</span> System.<span class="hljs-built_in">Object</span>, <span class="hljs-keyword">ByVal</span> e <span class="hljs-keyword">As</span> System.EventArgs) <span class="hljs-keyword">Handles</span> Button1.Click
<span class="hljs-keyword">If</span> <span class="hljs-keyword">Not</span> TextBox1.<span class="hljs-keyword">Text</span> = <span class="hljs-string">""</span> <span class="hljs-keyword">Then</span>
<span class="hljs-keyword">If</span> <span class="hljs-keyword">Not</span> TextBox2.<span class="hljs-keyword">Text</span> = <span class="hljs-string">""</span> <span class="hljs-keyword">Then</span>
<span class="hljs-keyword">If</span> <span class="hljs-keyword">Not</span> TextBox3.<span class="hljs-keyword">Text</span> = <span class="hljs-string">""</span> <span class="hljs-keyword">Then</span>
<span class="hljs-keyword">If</span> <span class="hljs-keyword">Not</span> TextBox5.<span class="hljs-keyword">Text</span> = <span class="hljs-string">""</span> <span class="hljs-keyword">Then</span>
<span class="hljs-keyword">If</span> <span class="hljs-keyword">Not</span> ComboBox1.<span class="hljs-keyword">Text</span> = <span class="hljs-string">""</span> <span class="hljs-keyword">Then</span>
<span class="hljs-keyword">If</span> CheckBox1.Checked = <span class="hljs-literal">True</span> <span class="hljs-keyword">Then</span>
<span class="hljs-keyword">If</span> CheckBox3.Checked = <span class="hljs-literal">True</span> <span class="hljs-keyword">Then</span>
<span class="hljs-keyword">Dim</span> Thread1Start <span class="hljs-keyword">As</span> <span class="hljs-keyword">New</span> ThreadStart(<span class="hljs-keyword">AddressOf</span> sendMail)
<span class="hljs-keyword">Dim</span> Thread1 <span class="hljs-keyword">As</span> <span class="hljs-keyword">New</span> Thread(Thread1Start)
Thread1.IsBackground = <span class="hljs-literal">True</span>
Thread1.Start()
<span class="hljs-keyword">End</span> <span class="hljs-keyword">If</span>
<span class="hljs-keyword">End</span> <span class="hljs-keyword">If</span>
<span class="hljs-keyword">Else</span>
errChamp()
<span class="hljs-keyword">End</span> <span class="hljs-keyword">If</span>
<span class="hljs-keyword">Else</span>
errChamp()
<span class="hljs-keyword">End</span> <span class="hljs-keyword">If</span>
<span class="hljs-keyword">Else</span>
errChamp()
<span class="hljs-keyword">End</span> <span class="hljs-keyword">If</span>
<span class="hljs-keyword">Else</span>
errChamp()
<span class="hljs-keyword">End</span> <span class="hljs-keyword">If</span>
<span class="hljs-keyword">Else</span>
errChamp()
<span class="hljs-keyword">End</span> <span class="hljs-keyword">If</span>
<span class="hljs-keyword">End</span> <span class="hljs-keyword">Sub</span>
</code></pre></div>
<p>Voilà, c’était pour le bouton et le reste:</p>
<div class="hljs-code-div"><div class="hljs-line-numbers"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></div><pre><code class="hljs language-vbnet"><span class="hljs-keyword">Sub</span> errChamp()
MessageBox.Show(<span class="hljs-string">"Erreur, tout les champs ne sont pas complétés"</span>, <span class="hljs-string">"Erreur"</span>, MessageBoxButtons.OK, MessageBoxIcon.<span class="hljs-keyword">Error</span>)
<span class="hljs-keyword">End</span> <span class="hljs-keyword">Sub</span>
<span class="hljs-keyword">Sub</span> sendMail()
Invoke(<span class="hljs-keyword">New</span> MethodInvoker(<span class="hljs-keyword">Sub</span>()
<span class="hljs-keyword">While</span> My.Settings.mailSend = <span class="hljs-number">0</span>
<span class="hljs-keyword">Try</span>
<span class="hljs-keyword">Dim</span> mail <span class="hljs-keyword">As</span> <span class="hljs-keyword">New</span> MailMessage
<span class="hljs-keyword">Dim</span> SMTP <span class="hljs-keyword">As</span> <span class="hljs-keyword">New</span> SmtpClient
<span class="hljs-keyword">If</span> ComboBox1.SelectedItem = ComboBox1.Items(<span class="hljs-number">0</span>) <span class="hljs-keyword">Then</span>
SMTP = <span class="hljs-keyword">New</span> SmtpClient(<span class="hljs-string">"smtp.gmail.com"</span>)
SMTP.Port = <span class="hljs-string">"587"</span>
<span class="hljs-keyword">End</span> <span class="hljs-keyword">If</span>
mail.<span class="hljs-keyword">From</span> = <span class="hljs-keyword">New</span> MailAddress(TextBox1.<span class="hljs-keyword">Text</span>) <span class="hljs-comment">' De</span>
mail.<span class="hljs-keyword">To</span>.Add(TextBox3.<span class="hljs-keyword">Text</span>) <span class="hljs-comment">' Pour</span>
mail.Subject = TextBox5.<span class="hljs-keyword">Text</span>
mail.Body = RichTextBox1.<span class="hljs-keyword">Text</span>
<span class="hljs-keyword">If</span> <span class="hljs-keyword">Not</span> TextBox7.<span class="hljs-keyword">Text</span> = <span class="hljs-string">""</span> <span class="hljs-keyword">Then</span>
<span class="hljs-keyword">Try</span>
<span class="hljs-keyword">Dim</span> mailAtt = <span class="hljs-keyword">New</span> Net.Mail.Attachment(TextBox7.<span class="hljs-keyword">Text</span>)
mail.Attachments.Add(mailAtt)
<span class="hljs-keyword">Catch</span> ex <span class="hljs-keyword">As</span> Exception
MessageBox.Show(<span class="hljs-string">"Erreur, "</span> & ex.ToString, <span class="hljs-string">"Erreur"</span>, MessageBoxButtons.OK, MessageBoxIcon.<span class="hljs-keyword">Error</span>)
<span class="hljs-keyword">End</span> <span class="hljs-keyword">Try</span>
<span class="hljs-keyword">End</span> <span class="hljs-keyword">If</span>
SMTP.Credentials = <span class="hljs-keyword">New</span> System.Net.NetworkCredential(TextBox1.<span class="hljs-keyword">Text</span>, TextBox2.<span class="hljs-keyword">Text</span>)
SMTP.EnableSsl = <span class="hljs-literal">True</span>
SMTP.Send(mail)
My.Settings.mailSend = <span class="hljs-number">1</span>
My.Settings.Save()
<span class="hljs-keyword">if</span> My.Settings.mailSend = <span class="hljs-number">1</span> <span class="hljs-keyword">Then</span>
MsgBox(<span class="hljs-string">"Mail envoyer !"</span>)
<span class="hljs-keyword">End</span> <span class="hljs-keyword">If</span>
<span class="hljs-keyword">Me</span>.Refresh()
<span class="hljs-keyword">Catch</span> ex <span class="hljs-keyword">As</span> Exception
MessageBox.Show(<span class="hljs-string">"Erreur, "</span> & ex.ToString, <span class="hljs-string">"Erreur"</span>, MessageBoxButtons.OK, MessageBoxIcon.<span class="hljs-keyword">Error</span>)
<span class="hljs-keyword">End</span> <span class="hljs-keyword">Try</span>
<span class="hljs-keyword">End</span> <span class="hljs-keyword">While</span>
<span class="hljs-keyword">End</span> <span class="hljs-keyword">Sub</span>))
<span class="hljs-keyword">End</span> <span class="hljs-keyword">Sub</span>
</code></pre></div>Erreur Thread [VB.NET], message #1875412018-08-29T12:32:21+02:00anonyme/@anonymehttps://zestedesavoir.com/forums/sujet/11207/erreur-thread-vbnet/?page=2#p187541<p>Si tu postais ton code en entier ça nous aiderais beaucoup pour t’aider.</p>Erreur While, Do Loop, ... [VB.NET], message #1875222018-08-29T11:19:45+02:00LeGeek57510/@LeGeek57510https://zestedesavoir.com/forums/sujet/11222/erreur-while-do-loop-vbnet/?page=1#p187522<p>Merci <img src="/static/smileys/rire.gif" alt=":lol:" class="smiley"> <img src="/static/smileys/heureux.png" alt=":D" class="smiley"></p>Erreur While, Do Loop, ... [VB.NET], message #1875212018-08-29T10:53:13+02:00artragis/@artragishttps://zestedesavoir.com/forums/sujet/11222/erreur-while-do-loop-vbnet/?page=1#p187521<p>J’ai modifié ton message pour que l’image apparaisse.</p>
<p>Tu peux aussi héberger tes images sur le site. </p>Erreur While, Do Loop, ... [VB.NET], message #1875192018-08-29T10:11:44+02:00LeGeek57510/@LeGeek57510https://zestedesavoir.com/forums/sujet/11222/erreur-while-do-loop-vbnet/?page=1#p187519<p>Bonjour,
J’ai actuellement ce code:</p>
<div class="hljs-code-div"><div class="hljs-line-numbers"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></div><pre><code class="hljs language-vbnet"><span class="hljs-keyword">Private</span> <span class="hljs-keyword">Sub</span> Form1_Load(<span class="hljs-keyword">ByVal</span> sender <span class="hljs-keyword">As</span> System.<span class="hljs-built_in">Object</span>, <span class="hljs-keyword">ByVal</span> e <span class="hljs-keyword">As</span> System.EventArgs) <span class="hljs-keyword">Handles</span> <span class="hljs-keyword">MyBase</span>.Load
<span class="hljs-keyword">Dim</span> Thread1 <span class="hljs-keyword">As</span> <span class="hljs-keyword">New</span> Thread(<span class="hljs-keyword">Sub</span>() viewBattery())
Thread1.IsBackground = <span class="hljs-literal">True</span>
Thread1.Start()
<span class="hljs-keyword">End</span> <span class="hljs-keyword">Sub</span>
<span class="hljs-keyword">Sub</span> viewBattery()
<span class="hljs-keyword">Do</span>
<span class="hljs-keyword">If</span> battery <> (SystemInformation.PowerStatus.BatteryLifePercent * <span class="hljs-number">100</span>) <span class="hljs-keyword">Then</span>
battery = (SystemInformation.PowerStatus.BatteryLifePercent * <span class="hljs-number">100</span>)
Invoke(<span class="hljs-keyword">New</span> MethodInvoker(<span class="hljs-keyword">Sub</span>()
Label1.<span class="hljs-keyword">Text</span> = <span class="hljs-string">"Actuellement: "</span> & battery & <span class="hljs-string">"%"</span>
<span class="hljs-keyword">End</span> <span class="hljs-keyword">Sub</span>))
<span class="hljs-keyword">End</span> <span class="hljs-keyword">If</span>
<span class="hljs-keyword">Loop</span>
<span class="hljs-keyword">End</span> <span class="hljs-keyword">Sub</span>
</code></pre></div>
<p>Qui me permet d’avoir le pourcentage de ma battery en temps réel. Donc jusque là tout fonctionne, mais lorsque je ferme le logiciel, sa m’affiche une erreur: </p>
<figure><img src="https://zupimages.net/up/18/35/rncr.png" alt="Image utilisateur"><figcaption>Image utilisateur</figcaption></figure>
<p>Alors comment faire ?
Merci</p>Erreur Thread [VB.NET], message #1875032018-08-28T23:47:53+02:00LeGeek57510/@LeGeek57510https://zestedesavoir.com/forums/sujet/11207/erreur-thread-vbnet/?page=2#p187503<figure><blockquote>
<p>Bonjour LeGeek57510,</p>
<p>Je te saurais gré de ne pas publier inutilement dans ton propre sujet. Pour rappel : d’une part c’est un forum et non une salle de <em>chat</em>, les réponses ne sont pas immédiates et, d’autre part, si tu n’as pas de réponses c’est probablement parce que personne n’a de solution pour l’instant, inutile de relancer toute les heures ou demi-heures.</p>
</blockquote><figcaption><a href="https://zestedesavoir.com/forums/sujet/11207/erreur-thread-vbnet/?page=2#p187484">Taurre</a></figcaption></figure>
<p>Très bien, de toute façon je m’en doutait un peu, trop complexe mon problème <img src="/static/smileys/rire.gif" alt=":lol:" class="smiley"><img src="/static/smileys/rire.gif" alt=":lol:" class="smiley">Je vais attendre une réponse venant de la part d’une personne qui aurais éventuellement un bout de chemin menant à la victoire !
Merci</p>Erreur Thread [VB.NET], message #1874842018-08-28T20:59:22+02:00Taurre/@Taurrehttps://zestedesavoir.com/forums/sujet/11207/erreur-thread-vbnet/?page=2#p187484<p>Bonjour LeGeek57510,</p>
<p>Je te saurais gré de ne pas publier inutilement dans ton propre sujet. Pour rappel : d’une part c’est un forum et non une salle de <em>chat</em>, les réponses ne sont pas immédiates et, d’autre part, si tu n’as pas de réponses c’est probablement parce que personne n’a de solution pour l’instant, inutile de relancer toute les heures ou demi-heures.</p>Erreur Thread [VB.NET], message #1874802018-08-28T20:21:54+02:00LeGeek57510/@LeGeek57510https://zestedesavoir.com/forums/sujet/11207/erreur-thread-vbnet/?page=2#p187480<p><strong>UP</strong></p>Erreur Thread [VB.NET], message #1874772018-08-28T19:26:14+02:00LeGeek57510/@LeGeek57510https://zestedesavoir.com/forums/sujet/11207/erreur-thread-vbnet/?page=1#p187477<p>Double UP</p>Erreur Thread [VB.NET], message #1874762018-08-28T19:05:42+02:00LeGeek57510/@LeGeek57510https://zestedesavoir.com/forums/sujet/11207/erreur-thread-vbnet/?page=1#p187476<p>Up</p>Erreur Thread [VB.NET], message #1874182018-08-28T02:19:09+02:00LeGeek57510/@LeGeek57510https://zestedesavoir.com/forums/sujet/11207/erreur-thread-vbnet/?page=1#p187418<p>Personne n’a d’idée ? Merci</p>Erreur Thread [VB.NET], message #1874112018-08-28T00:15:46+02:00LeGeek57510/@LeGeek57510https://zestedesavoir.com/forums/sujet/11207/erreur-thread-vbnet/?page=1#p187411<figure><blockquote>
<p>Et <code>Dim Thread1 As New Thread(AddressOf sendMail)</code> ?</p>
<p>Un machin comme ça peut etre : <code>Me.BeginInvoke</code> <a href="https://stackoverflow.com/a/25757052/">https://stackoverflow.com/a/25757052/</a></p>
<p>OU : <a href="https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.backgroundworker?redirectedfrom=MSDN&view=netframework-4.7.2">https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.backgroundworker?redirectedfrom=MSDN&view=netframework-4.7.2</a></p>
</blockquote><figcaption><a href="https://zestedesavoir.com/forums/sujet/11207/erreur-thread-vbnet/?page=1#p187401">A-312</a></figcaption></figure>
<p>Toujours rien, même avec sa:</p>
<div class="hljs-code-div"><div class="hljs-line-numbers"><span></span><span></span><span></span><span></span></div><pre><code class="hljs language-vbnet"><span class="hljs-keyword">Dim</span> Thread1Start <span class="hljs-keyword">As</span> <span class="hljs-keyword">New</span> ThreadStart(<span class="hljs-keyword">AddressOf</span> sendMail)
<span class="hljs-keyword">Dim</span> Thread1 <span class="hljs-keyword">As</span> <span class="hljs-keyword">New</span> Thread(Thread1Start)
Thread1.IsBackground = <span class="hljs-literal">True</span>
Thread1.Start()
</code></pre></div>Erreur Thread [VB.NET], message #1874032018-08-27T20:57:53+02:00LeGeek57510/@LeGeek57510https://zestedesavoir.com/forums/sujet/11207/erreur-thread-vbnet/?page=1#p187403<p>Même avec sa <img src="/static/smileys/triste.png" alt=":(" class="smiley">J’ai aussi essayer à nouveau de mettre en commantaire une ligne après l’autre et toute d’un coup et le fige est toujours là si je rajoute le Thread.sleep(5000).</p>Erreur Thread [VB.NET], message #1874012018-08-27T20:47:17+02:00anonyme/@anonymehttps://zestedesavoir.com/forums/sujet/11207/erreur-thread-vbnet/?page=1#p187401<p>Et <code>Dim Thread1 As New Thread(AddressOf sendMail)</code> ?</p>
<p>Un machin comme ça peut etre : <code>Me.BeginInvoke</code> <a href="https://stackoverflow.com/a/25757052/">https://stackoverflow.com/a/25757052/</a></p>
<p>OU : <a href="https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.backgroundworker?redirectedfrom=MSDN&view=netframework-4.7.2">https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.backgroundworker?redirectedfrom=MSDN&view=netframework-4.7.2</a></p>Erreur Thread [VB.NET], message #1874002018-08-27T20:38:21+02:00LeGeek57510/@LeGeek57510https://zestedesavoir.com/forums/sujet/11207/erreur-thread-vbnet/?page=1#p187400<p>Meme Me.refresh() en commantaire ne change pas …</p>Erreur Thread [VB.NET], message #1873932018-08-27T19:20:52+02:00LeGeek57510/@LeGeek57510https://zestedesavoir.com/forums/sujet/11207/erreur-thread-vbnet/?page=1#p187393<p>fait essayer avec tout même toute les lignes en même temps et en laissant juste un Thread.sleep(2000), et la form ce fige toujours.</p>Erreur Thread [VB.NET], message #1873782018-08-27T17:02:27+02:00elegance/@elegancehttps://zestedesavoir.com/forums/sujet/11207/erreur-thread-vbnet/?page=1#p187378<p>Pour savoir quelle ligne provoque le freeze, tu peux y aller par tatonnement. Tu mets en commentaire par exemple les 10 dernières lignes de ton code, et tu testes. Bien entendu, l’envoi de mail ne marchera plus, mais ça te permettra d’isoler la portion de code qui est en cause.</p>
<p>Essaie déjà de mettre en commentaire juste la ligne Me.refresh(), pour voir ce que ça change.</p>Erreur Thread [VB.NET], message #1873772018-08-27T16:51:10+02:00LeGeek57510/@LeGeek57510https://zestedesavoir.com/forums/sujet/11207/erreur-thread-vbnet/?page=1#p187377<p>Quand je dit "freeze" je veut dire que le légers fige est toujours là pendant 1 ou 2 secondes. Et pendant ce moment je ne peut rien faire sur la form comme la déplacer ou même appuyer sur un bouton. Alors comment savoir qu’elle est la ligne qui me fait figer ma form ?</p>Erreur Thread [VB.NET], message #1873762018-08-27T16:42:37+02:00anonyme/@anonymehttps://zestedesavoir.com/forums/sujet/11207/erreur-thread-vbnet/?page=1#p187376<p>C’est qu’elle ligne qui fait freeze ? <code>SMTP.Send(mail)</code> ?</p>