Option Explicit
' ======================================================================
' =                                         INITALISATION DU FORMULAIRE                                                =
' ======================================================================
' Initialisation du UserForm usf_NonMembre
' ---------------------------------------------------------------------------------------------------------------------------
' Initialisation du UserForm usf_NonMembre
' ---------------------------------------------------------------------------------------------------------------------------
Private Sub UserForm_Initialize()
Dim Ctrl As Control
Dim i As Byte

For i = 1 To 2
    With Me.Controls(Textbox & i)
        .Value = 
        .BackColor = &H80000016
        .Font.Bold = True
    End With
    'If i = 3 Then Me.Controls(Textbox & i).Visible = False
Next i
'TextBox3.Visible = False
End Sub

' ======================================================================
' =                              CONFIGURATION DE LA TEXTBOX NOM                                         =
' ======================================================================
' Au format MAJUSCULE
' ---------------------------------------------------------------------------------------------------------------------------
Private Sub TextBox1_Change()

TextBox1.Value = UCase(TextBox1.Value)

End Sub

' ======================================================================
' =                           CONFIGURATION DE LA TEXTBOX Prenom                                        =
' ======================================================================
' 1ere lettre en Majuscule
' ---------------------------------------------------------------------------------------------------------------------------
Private Sub TextBox2_Change()

TextBox2.Value = Application.Proper(TextBox2.Value)

End Sub

' ======================================================================
' =                               CONFIGURATION DU BOUTON Inscrire                                            =
' ======================================================================
' Permet d'enregistrer un joueur non membre du club au concours
' ---------------------------------------------------------------------------------------------------------------------------
Private Sub CommandButton1_Click()
Dim lastRw As Long
Dim L As Byte

For L = 1 To 2
        
    If Controls(TextBox & L).Value =  Then
        MsgBox Vous n'avez pas rempli ce champ, vbOKOnly + vbCritical, Alerte
        Me.Controls(TextBox & L).SetFocus
        Exit Sub
    End If

Next L

If OptionButton1 = False And OptionButton2 = False Then MsgBox Choisir un sexe Exit Sub

Set Sh2 = Inscriptions

With Sh2
    
    lastRw = .Cells(Rows.Count, 1).End(xlUp).Row + 1
    .Cells(lastRw, 1).Value = NM & WorksheetFunction.CountIf(Sh2.Range(A2A & lastRw), =NM) + 1 'ID
    .Cells(lastRw, 2).Value = TextBox1.Value 'Nom
    .Cells(lastRw, 3).Value = TextBox2.Value 'prenom
    If OptionButton1 = True Then 'sexe
        .Cells(lastRw, 4).Value = H
    Else .Cells(lastRw, 4).Value = F
    End If
    If Me.CheckBox1 = True Then .Cells(lastRw, 5) = X 'tireur
    If Me.CheckBox2 = True Then .Cells(lastRw, 6) = X 'milieu
    If Me.CheckBox3 = True Then .Cells(lastRw, 7) = X 'pointeur
    'couleur rouge cas nom membre
    If .Cells(lastRw, 1).Value Like NM Then .Range(A & lastRw & G & lastRw).Font.Color = -16776961
        
End With

Call usf_Inscription.InitListe2

Unload Me
        
End Sub
 
 ' ======================================================================
' =                                           QUITTER LE FORMULAIRE                                                            =
' ======================================================================
' Bouton Quitter dans Userform usf_NonMembre
' ---------------------------------------------------------------------------------------------------------------------------
Private Sub CommandButton2_Click()

Unload Me

End Sub
