0/5 (10 avis)
Snippet vu 8 424 fois - Téléchargée 34 fois
'Code à mettre dans votre Feuille 'Votre textBox : Text1 Private LockedLength As Long Private LockedString As String Private Sub Text1_Change() If LockedLength = 0 Or LockedString = "" Then Exit Sub TextBoxLocker Text1, -1 End Sub Private Sub Text1_KeyPress(KeyAscii As Integer) KeyAscii = TextBoxLocker(Text1, KeyAscii, "Shell> ") End Sub Public Function TextBoxLocker(ByVal ObjTextBox As TextBox, ByRef KeyAscii As Integer, Optional Chaine As String = "") As Integer If KeyAscii = -1 Then If Left(ObjTextBox.Text, LockedLength) <> LockedString Then ObjTextBox.Text = LockedString ObjTextBox.SelStart = LockedLength End If Exit Function End If TextBoxLocker = KeyAscii If ObjTextBox.SelStart < LockedLength Then ObjTextBox.SelStart = LockedLength TextBoxLocker = 0 Exit Function End If Select Case KeyAscii Case 8 If ObjTextBox.SelStart <= LockedLength Then TextBoxLocker = 0 Exit Function End If Case 13 ObjTextBox.Text = ObjTextBox.Text & vbNewLine & Chaine ObjTextBox.SelStart = Len(ObjTextBox.Text) LockedLength = Len(ObjTextBox.Text) LockedString = Left(ObjTextBox.Text, LockedLength) TextBoxLocker = 0 End Select End Function
27 août 2004 à 16:59
27 août 2004 à 16:45
If Left(ObjTextBox.Text, LockedLength) <> LockedString Then
ObjTextBox.Text = LockedString
ObjTextBox.SelStart = LockedLength
End If
27 août 2004 à 16:11
if LockedString <> mid(textebox1.text,1,len(LockedString ) then
'Erreur
end if
27 août 2004 à 16:03
27 août 2004 à 15:45
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.