Public WithEvents Txtb As MSForms.TextBox
Dim cls() As New UserForm1
Public oldcontrol As MSForms.TextBox
Private Sub Txtb_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If Not UserForm1.oldcontrol Is Nothing Then
If UserForm1.oldcontrol.Name <> Txtb.Name Then
If UserForm1.oldcontrol.Text = "" Then UserForm1.oldcontrol.Text = "Saisir ICI le nom de l'ouvrage": UserForm1.oldcontrol.ForeColor = RGB(200, 200, 200)
End If
End If
If Button = 1 Then
If Txtb.Text = "Saisir ICI le nom de l'ouvrage" Then Txtb.Text = "": Txtb.ForeColor = vbBlack
Set UserForm1.oldcontrol = UserForm1.Controls(Txtb.Name)
End If
End Sub
Private Sub UserForm_Activate()
For i = 1 To 10: X = X + 1
ReDim Preserve cls(1 To X): Set cls(X).Txtb = Me.Controls("TextBox" & X)
With Me.Controls("TextBox" & X): .Text = "Saisir ICI le nom de l'ouvrage": .ForeColor = RGB(200, 200, 200): End With
Next
End Sub
Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If Not oldcontrol Is Nothing Then If oldcontrol.Text = "" Then oldcontrol.Text = "Saisir ICI le nom de l'ouvrage": oldcontrol.ForeColor = RGB(200, 200, 200)
End Sub