Bonjour.
Je suis débutante en vb, mais je suis ammenée à toucher à du code. Et il me faut manipuler un bout pour passer un Nom en majuscule automatiquement.
Pour le moment, on tape le nom et seulement la premiere lettre se met en majuscule automatiquement. J'aimerais savoir comment tout passer en majuscule.
Voici le morceau de code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 Public Sub Nom_cdtTextBox_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Nom_cdtTextBox.KeyPress Dim pos As Integer pos = Nom_cdtTextBox.SelectionStart If Nom_cdtTextBox.SelectionStart = 0 Then If e.KeyChar = "a" Then e.Handled = True Nom_cdtTextBox.Text = Nom_cdtTextBox.Text.Insert(pos, "A") End If If e.KeyChar = "b" Then e.Handled = True Nom_cdtTextBox.Text = Nom_cdtTextBox.Text.Insert(pos, "B") End If ... If e.KeyChar = "y" Then e.Handled = True Nom_cdtTextBox.Text = Nom_cdtTextBox.Text.Insert(pos, "Y") End If If e.KeyChar = "z" Then e.Handled = True Nom_cdtTextBox.Text = Nom_cdtTextBox.Text.Insert(pos, "Z") End If Nom_cdtTextBox.SelectionStart = pos + 1 'on avance le curseur d'un caractère End If Dim pos2 As String pos2 = UCase(Nom_cdtTextBox) 'renvoie le tout en majuscule End Sub
Partager