Err 13 - Incompatibilité de Type - Calcul sur TextBox
Err 13 - Incompatibilité de Type - Calcul sur TextBox
Code problème début dans UserForm2
Code:
chq_Total = Me.TextBox14 + Me.TextBox15 + Me.TextBox16 + Me.TextBox17 + Me.TextBox18 + Me.TextBox19 + Me.TextBox20 + Me.TextBox21 + Me.TextBox22 + Me.TextBox23
Plusieurs essaie sur le même theme !
L'addition fct avec les 2 premiers TBox Mais ca me donne un chiffre concatener
TBox 14 +Tbox15
25+26 =2526 au lieu de 51
Code:
1 2 3 4 5 6
| 'chq_Total = Me.TextBox14 + Me.TextBox15
chq_Total = Me.TextBox14 + Me.TextBox15 + Me.TextBox16 + Me.TextBox17 + Me.TextBox18 + Me.TextBox19 + Me.TextBox20 + Me.TextBox21 + Me.TextBox22 + Me.TextBox23
'chq_Total = Me.TextBox14 * 1 + Me.TextBox15 * 1 + Me.TextBox16 * 1 + Me.TextBox17 * 1 + Me.TextBox18 * 1 + Me.TextBox19 * 1 + Me.TextBox20 * 1 + Me.TextBox21 * 1 + Me.TextBox22 * 1 + Me.TextBox23 * 1
'Total_ch = Format(45.23, "Currency")
Total_ch = chq_Total
UserForm1.TextBox17.Value = Sheets("Lst").Range("DsumCH") |
J'ai tenter de corriger avec le code suivant (Une variante de solution trouvez ici) et plusieurs hres de lecture
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| Sub PH_validate()
Dim Ctrl As Control
For Each Ctrl In UserForm2.Controls
If TypeName(Ctrl) = "TextBox" Then
MsgBox VarType(Ctrl) & " TB " & Ctrl
If IsNumeric(Ctrl) Then
Ctrl = Format(Ctrl.Value, "Currency")
MsgBox Ctrl & " Numeric" 'CurrencyTransform (Ctrl)
Else: MsgBox "Not Numeric Tbox"
End If
Else: MsgBox Ctrl & " Not TBox"
End If
Next Ctrl
End Sub |
Ca me dit que les chiffres sont bien en place mais le code continue de traiter ça comme du texte !
Je comprend pas pour les textBox traite les chiffres comme du texte et les + comme des &
Comment on peut débugger ça ? TRouver mon erreur ?
Merci
Note: les Dim sont OK (A mon avis !)
Code:
1 2 3 4 5 6 7 8 9
| Option Explicit
Dim Ws2 As Worksheet
Dim cd_Secteur As String
Dim cd_Depot As String
Dim p_Date As Date
Dim Total_ch As Currency
Private Sub CalculCH()
Dim chq_Total As Currency |