[VBA] - Probleme de caractères
Résolu
jeyjey1
-
anis -
anis -
Bonjour,
J'ai un bout de code qui fonctionne, mais pas comme je veux, le probleme se situe ligne 1 dans ma condition
comment dire que si ma textbox comporte que 5 caractère alors on continue,parce que dans le code ci-dessous si j'en ai + de 5 alors on continue, moi j'en veux que 5, pas 4 ni 6, mais 5
1 - If TextBoxReferenceProduit.Value = Left(TextBoxReferenceProduit.Value, 5) Then
2 - .Value = "'" & Left(LTrim(UserForm2.TextBoxReferenceProduit.Value), 5) + UserForm2.TextBoxVersion.Value +
3- UserForm2.TextBoxIndice.Value + UserForm2.TextBoxSup.Value 'Gestion du zéro
4 - End If
Quelqu'un aurait une idée s'il vous plait
Merci
Jeyjey1
J'ai un bout de code qui fonctionne, mais pas comme je veux, le probleme se situe ligne 1 dans ma condition
comment dire que si ma textbox comporte que 5 caractère alors on continue,parce que dans le code ci-dessous si j'en ai + de 5 alors on continue, moi j'en veux que 5, pas 4 ni 6, mais 5
1 - If TextBoxReferenceProduit.Value = Left(TextBoxReferenceProduit.Value, 5) Then
2 - .Value = "'" & Left(LTrim(UserForm2.TextBoxReferenceProduit.Value), 5) + UserForm2.TextBoxVersion.Value +
3- UserForm2.TextBoxIndice.Value + UserForm2.TextBoxSup.Value 'Gestion du zéro
4 - End If
Quelqu'un aurait une idée s'il vous plait
Merci
Jeyjey1
A voir également:
- [VBA] - Probleme de caractères
- Caractères spéciaux - Guide
- Caractères ascii - Guide
- Caracteres speciaux - Guide
- Caractères spéciaux mac - Guide
- Exemple de mot de passe à 8 caractères - Guide
5 réponses
Tu peux tester la longueur du champ avec le OnKeyPress.
If Len(Me.TextBoxReferenceProduit) >= 5 Then ' éviter Copy/Paste
InputCharacter = Chr(0)
End If
Puis encore pour gérer Copy/Paste
OnExit
Me.TextBoxReferenceProduit = Left(Me.TextBoxReferenceProduit, 5)
If Len(Me.TextBoxReferenceProduit) >= 5 Then ' éviter Copy/Paste
InputCharacter = Chr(0)
End If
Puis encore pour gérer Copy/Paste
OnExit
Me.TextBoxReferenceProduit = Left(Me.TextBoxReferenceProduit, 5)
Merci Phil232 pour ton aide précieuse
Ci joint mon code final avec la soluce de Phil232
If Len(TextBoxReferenceProduit.Value) = 7 Then
.Value = "'" & Left(LTrim(UserForm2.TextBoxReferenceProduit.Value), 5) + UserForm2.TextBoxVersion.Value + UserForm2.TextBoxIndice.Value + UserForm2.TextBoxSup.Value 'Gestion du zéro
Else
.Value = "'" & Left(LTrim(UserForm2.TextBoxReferenceProduit.Value), 10) + UserForm2.TextBoxVersion.Value + UserForm2.TextBoxIndice.Value + UserForm2.TextBoxSup.Value 'Gestion du zéro
End If
Merci encore
Ci joint mon code final avec la soluce de Phil232
If Len(TextBoxReferenceProduit.Value) = 7 Then
.Value = "'" & Left(LTrim(UserForm2.TextBoxReferenceProduit.Value), 5) + UserForm2.TextBoxVersion.Value + UserForm2.TextBoxIndice.Value + UserForm2.TextBoxSup.Value 'Gestion du zéro
Else
.Value = "'" & Left(LTrim(UserForm2.TextBoxReferenceProduit.Value), 10) + UserForm2.TextBoxVersion.Value + UserForm2.TextBoxIndice.Value + UserForm2.TextBoxSup.Value 'Gestion du zéro
End If
Merci encore
Oups,
tu es sure que ça fonctionnera comme voulu ? On doit donc tapper 7 fois pour récuperer 5 caractères ? Sinon, même s'il n'y a qu'un caractère tu fait un Left(xxx, 10) avec ?
tu es sure que ça fonctionnera comme voulu ? On doit donc tapper 7 fois pour récuperer 5 caractères ? Sinon, même s'il n'y a qu'un caractère tu fait un Left(xxx, 10) avec ?
Enfait si ma textbox comporte 7 caracteres, les 5 premiers caracteres sont copiés dans une cellule voisine et ensuite je refais la meme chose sauf que la je copie les 10 premiers caracteres
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question