Option Explicit
Implements CAsso
Private Parent As ControlsAssociés, WithEvents TBx As MSForms.TextBox, Index As Long, Colonne As Long, Format As String, UsMode
Private Sub CAsso_Init(ByVal Lui As ControlsAssociés, ByVal Ctl As MSForms.IControl, ByVal Idx As Long, _
ByVal Col As Long, ByVal Fmt As String, ByVal Mode As Variant)
Set Parent = Lui: Set TBx = Ctl: Index = Idx: Colonne = Col: Format = Fmt: UsMode = Mode
End Sub
Private Function CAsso_Ctl() As MSForms.IControl
Set CAsso_Ctl = TBx
End Function
Private Function CAsso_Index() As Long
CAsso_Index = Index
End Function
Private Function CAsso_Col() As Long
CAsso_Col = Colonne
End Function
Private Function CAsso_Format() As String
CAsso_Format = Format
End Function
Private Function CAsso_Mode() As Variant
CAsso_Mode = UsMode
End Function
Private Property Let CAsso_Valeur(ByVal RHS As Variant)
If IsEmpty(RHS) Then TBx.Text = "": Exit Property
TBx.Text = VBA.Format$(RHS, Format)
End Property
Private Property Get CAsso_Valeur() As Variant
If TBx.Text = "" Then
CAsso_Valeur = Empty
ElseIf IsDate(TBx.Text) And Not Format Like "*&*" Then
CAsso_Valeur = CDate(TBx.Text)
ElseIf IsNumeric(TBx.Text) And Not Format Like "*&*" Then
If Format Like "*€" Then CAsso_Valeur = CCur(TBx.Text) Else CAsso_Valeur = CDbl(TBx.Text)
Else
CAsso_Valeur = Trim$(TBx.Text)
End If
End Property
Private Sub TBx_Change()
Parent.CAM_Change Me
End Sub
Private Sub TBx_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Parent.CAM_KeyDown Me, KeyCode, Shift
End Sub
Private Sub TBx_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Parent.CAM_KeyPress Me, KeyAscii
End Sub
Private Sub TBx_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Parent.CAM_KeyUp Me, KeyCode, Shift
End Sub