Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Saisie obligatoire dans un texbox 2

3 réponses
Avatar
Milan DESHAYES
Bonsoir
Dans un textbox, je souhaite que le troisième caractère saisi soit
obligatoirement un 8 ou un 9
Je vous remercie

3 réponses

Avatar
PascalXLD
On 17 sep, 21:03, "Milan DESHAYES" wrote:
Bonsoir
Dans un textbox, je souhaite que le troisième caractère saisi soit
obligatoirement un 8 ou un 9
Je vous remercie


Bonjour

Une petite piste

If Mid(Me.TextBox1, 3, 1) <> "8" And Mid(Me.TextBox1, 3, 1) <> "9"
Then MsgBox "erreur"

Avatar
lSteph
Bonjour,

Private Sub TextBox1_Change()
Dim tst As Boolean
tst = False
If Len(TextBox1) >= 3 Then
Select Case Mid(TextBox1, 3, 1)
Case "8", "9"
tst = True
Case Else
Application.EnableEvents = False
TextBox1 = Left(TextBox1, 2)
Application.EnableEvents = True
MsgBox "le 3eme chr doit être 8 ou 9"
End Select
End If
End Sub

'lSteph





On 18 sep, 13:46, PascalXLD wrote:
On 17 sep, 21:03, "Milan DESHAYES" wrote:

Bonsoir
Dans un textbox, je souhaite que le troisième caractère saisi soit
obligatoirement un 8 ou un 9
Je vous remercie


Bonjour

Une petite piste

If Mid(Me.TextBox1, 3, 1) <> "8" And Mid(Me.TextBox1, 3, 1) <> "9"
Then MsgBox "erreur"



Avatar
Milan DESHAYES
Parfait !!!!!!!!!

"lSteph" a écrit dans le message de news:

Bonjour,

Private Sub TextBox1_Change()
Dim tst As Boolean
tst = False
If Len(TextBox1) >= 3 Then
Select Case Mid(TextBox1, 3, 1)
Case "8", "9"
tst = True
Case Else
Application.EnableEvents = False
TextBox1 = Left(TextBox1, 2)
Application.EnableEvents = True
MsgBox "le 3eme chr doit être 8 ou 9"
End Select
End If
End Sub

'lSteph





On 18 sep, 13:46, PascalXLD wrote:
On 17 sep, 21:03, "Milan DESHAYES" wrote:

Bonsoir
Dans un textbox, je souhaite que le troisième caractère saisi soit
obligatoirement un 8 ou un 9
Je vous remercie


Bonjour

Une petite piste

If Mid(Me.TextBox1, 3, 1) <> "8" And Mid(Me.TextBox1, 3, 1) <> "9"
Then MsgBox "erreur"