J'ai un msg d'erreur qui apparait à chaque fois que j'appuie sur le bouton "annuler" pour effacer les champs et plus précisément avec les champs "montant" et aussi quand j'essaye d'effacer un montant pour le réécrire dans le champ (tjrs au niveau des champ montant). Le msg d'erreur est le suivant : "La conversion de la chaîne " " en type 'Decimal' n'est pas valide".
Voici mon code :
le msg d'erreur apparaît a ce niveau :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 Private Sub Btnannuler_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnannuler.Click Txtnumc.Text = "" Txtlibc.Text = "" Dates.Text = "" Datef.Text = "" Txtmontantc.Text = "" Txtrea1ertrim.Text = "" Txtre2emetrim.Text = "" Txtrea3emetrim.Text = "" Txtrea4emetrim.Text = "" Txttotalrea.Text = "" Txtmontantpaye.Text = "" Txtmodpay.Text = "" Txtresteapayer.Text = "" Optoui.Checked = True Optnon.Checked = False Txtmontantavance.Text = "" Cbxnumm.Text = "" Txtlibm.Text = "" Cbxfrs.Text = "" Txtnumfrs.Text = "" Txtdureec.Text = "" End Sub Private Sub Txtmontantc_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Txtmontantc.TextChanged Txtmontantc.Text = Txtmontantc.Text.Replace(".", ",") Txtmontantc.Select(Txtmontantc.Text.Length, 0) Dim resultat As [Decimal] = CDec(Txtmontantc.Text) Txtresteapayer.Text = resultat.ToString End Sub Private Sub Txtrea1ertrim_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Txtrea1ertrim.TextChanged Txtrea1ertrim.Text = Txtrea1ertrim.Text.Replace(".", ",") Txtrea1ertrim.Select(Txtrea1ertrim.Text.Length, 0) Dim r As [Decimal] = CDec(Txtmontantc.Text) Dim res As [Decimal] = CDec(Txtrea1ertrim.Text) Dim resultat As [Decimal] = CDec(r) - CDec(res) Txtresteapayer.Text = resultat.ToString End Sub
Que faire?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 Private Sub Txtmontantc_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Txtmontantc.TextChanged Dim resultat As [Decimal] = CDec(Txtmontantc.Text) End Sub![]()
Partager