1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| '--- dans l'UserForm ---
Option Explicit
Private WithEvents USF As Classe1
Dim TB As Control
Private Sub UserForm_Initialize()
Dim L As Control
Dim B As Control
Set TB = UserForm1.Controls.Add("Forms.TextBox.1")
Set L = UserForm1.Controls.Add("Forms.Label.1")
Set B = UserForm1.Controls.Add("Forms.CommandButton.1")
L.BackColor = &H80000005
L.Left = TB.Width
B.Left = L.Left + L.Width
End Sub
Private Sub UserForm_Activate()
Set USF = New Classe1
TB.SetFocus
Me.Controls(Me.ActiveControl.Name). _
Object.BackColor = RGB(200, 200, 200)
USF.cibleFocus Me
End Sub
Private Sub USF_GetFocus()
If TypeName(Me.Controls(Me.ActiveControl.Name)) = "TextBox" Then Me.Controls(Me.ActiveControl.Name). _
Object.BackColor = RGB(200, 200, 200)
End Sub
Private Sub USF_LostFocus(ByVal Txtbx As String)
Me.Controls(Txtbx).BackColor = RGB(255, 255, 255)
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
Set USF = Nothing
End Sub |
Partager