Hello The community
In a form I have fields name, first name in which I would if necessary want to put the first letter of the name and/or the first name in uppercase. I created for it a buttonUPLOW How to synchronize this action.
Thanks to you all
Habiler
.
In a form I have fields name, first name in which I would if necessary want to put the first letter of the name and/or the first name in uppercase. I created for it a buttonUPLOW How to synchronize this action.
Thanks to you all
Habiler
Code:
Function MiseEnMajuscule(Chaine As String) As StringDim
nCar As Integer
[COLOR=Green]'Compteur (position dans la chaine à traiter) [/COLOR]
Chaine = Trim$(Chaine)
[COLOR=Green] 'Récupère la chaîne sans les espaces facultatifs
'Traitement spécifique sur le premier [/COLOR]
caractèreMiseEnMajuscule = UCase$(Left(Chaine, 1))
[COLOR=Green]'Début de la boucle sur les autres caractères[/COLOR]
For nCar = 2 To Len(Chaine)
[COLOR=Green]'Teste le caractère précédent (" " ou "-")[/COLOR]
If (Mid$(Chaine, nCar - 1, 1) = " ") Or (Mid$(Chaine, nCar - 1, 1) = "-") Then
[COLOR=Green]'Si c'est vrai, mettre en majuscule le caractère [/COLOR]
courantMiseEnMajuscule = MiseEnMajuscule & UCase$(Mid(Chaine, nCar, 1))
Else
[COLOR=Green]'Si c'est faux, mettre en minuscule le caractère [/COLOR]
courantMiseEnMajuscule = MiseEnMajuscule & LCase$(Mid(Chaine, nCar, 1))
End If
[COLOR=Green] 'Fin de la boucle sur les caractères[/COLOR]
Next
End Function
Last edited by a moderator: