treza88
XLDnaute Occasionnel
Bonsoir à tous
J'ai un petit souci avec le code ci-dessous, je ne comprend pourquoi quand le textbox1 est vide et que je le quitte il met renvoie le message d'erreur "incompatibilité de type" sur la ligne en rouge.
Si quelqu'un pouvait m'expliquer pourquoi ça m'arrangerait.
Pour palier a ce probleme j'ai rajouté un test sur une valeur nul sur le code tout en dessous, apparemment ça fonctionne, mais etait-ce la bonne solution?
Sinon quelle autre solution existe.
Merci
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim c As Variant
Dim h1 As Date
Application.ScreenUpdating = False
TextBox1.Value = TimeValue(Left(Application.Text(TextBox1.Value, "00.00"), 2) _
& ":" & Right(TextBox1.Value, 2))
c = TextBox1.Value
h1 = TextBox1.Value
TextBox1.Value = Format(c, "hh\H mm")
End Sub
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim c As Variant
Dim h1 As Date
Application.ScreenUpdating = False
If TextBox1.Value <> "" Then
TextBox1.Value = TimeValue(Left(Application.Text(TextBox1.Value, "00.00"), 2) _
& ":" & Right(TextBox1.Value, 2))
c = TextBox1.Value
h1 = TextBox1.Value
TextBox1.Value = Format(c, "hh\H mm")
End If
End Sub
J'ai un petit souci avec le code ci-dessous, je ne comprend pourquoi quand le textbox1 est vide et que je le quitte il met renvoie le message d'erreur "incompatibilité de type" sur la ligne en rouge.
Si quelqu'un pouvait m'expliquer pourquoi ça m'arrangerait.
Pour palier a ce probleme j'ai rajouté un test sur une valeur nul sur le code tout en dessous, apparemment ça fonctionne, mais etait-ce la bonne solution?
Sinon quelle autre solution existe.
Merci
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim c As Variant
Dim h1 As Date
Application.ScreenUpdating = False
TextBox1.Value = TimeValue(Left(Application.Text(TextBox1.Value, "00.00"), 2) _
& ":" & Right(TextBox1.Value, 2))
c = TextBox1.Value
h1 = TextBox1.Value
TextBox1.Value = Format(c, "hh\H mm")
End Sub
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim c As Variant
Dim h1 As Date
Application.ScreenUpdating = False
If TextBox1.Value <> "" Then
TextBox1.Value = TimeValue(Left(Application.Text(TextBox1.Value, "00.00"), 2) _
& ":" & Right(TextBox1.Value, 2))
c = TextBox1.Value
h1 = TextBox1.Value
TextBox1.Value = Format(c, "hh\H mm")
End If
End Sub