bonjour,
j aimerai savoir le code pour preremplir une textbox
par exemple j aimerai que lorsque mon userform apparait:
que l on puisse voir ds la textbox1 : " VOl / "
et que l utilisateur n est plus qu a mettre:
"Vol 1/2"
par exemple
merci
Version imprimable
bonjour,
j aimerai savoir le code pour preremplir une textbox
par exemple j aimerai que lorsque mon userform apparait:
que l on puisse voir ds la textbox1 : " VOl / "
et que l utilisateur n est plus qu a mettre:
"Vol 1/2"
par exemple
merci
Dans Userform_Initialize, tu mets
Code:Me.TextBox1 = " VOl / "
Oui, c'est possible.
Dans le code de ton userform, tu peux ajouter une fonction spéciale qui sert à initialiser ton userform. Un exemple ci-dessous:
Essaie, ça marche. Change quand même le nom par le nom de ta textbox...Code:
1
2
3
4 Public Sub UserForm_initialize() TextBox1.Value = " VOl / " End Sub
je fais un mixx de vous deux et j ai la bonne rep:
merciCode:
1
2
3 Private Sub Userform_initialize() Me.TextBox1 = "Vol / " End Sub
Bonjour,
Oh !
C'est tout ?
Bâclé pour bâclé, ... je reviens dans moins de 10 minutes, alors ...
Edit :
voilà donc du bâclé (super bâclé ... il y a un million de fois mieux à faire avec le seul évènement Change et l'opérateur Like...;))
C'est quand même mieux, non ?Code:
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 Private Sub UserForm_Initialize() TextBox1.Text = "VOL /" End Sub Private Sub TextBox1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) Dim pos As Integer If TextBox1.Text = "" Then TextBox1.Text = "VOL /" DoEvents pos = InStr(TextBox1.Text, "/") If Mid(TextBox1.Text, pos - 1, 1) = " " Then TextBox1.SelStart = 5: Exit Sub End If If Mid(TextBox1.Text, pos + 1, 1) = "" Then TextBox1.SelStart = Len(TextBox1.Text): Exit Sub End If End Sub Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) Dim toto As String, pos As Integer toto = TextBox1.Text pos = InStr(toto, "/") 'toto = TextBox1.Text If Mid(toto, pos - 1, 1) = " " Then Mid(toto, pos - 1, 1) = Chr(KeyCode) TextBox1.Text = toto KeyCode = 0 TextBox1.SelStart = Len(TextBox1.Text): Exit Sub End If If TextBox1.SelStart = 6 And KeyCode = 8 Then KeyCode = 0 TextBox1.Text = toto: Exit Sub End If If KeyCode = 8 And TextBox1.SelStart < 6 Then KeyCode = 0 End Sub
Je retiens surtout
Je pensais à quelque chose comme ça mais ne me suis plus souvenu de la syntaxe et ai eu la flemme d'aller la chercher dans l'aide.Code:if TextBox1 = "VOL /" then TextBox1.SelStart = 5
Merci donc, ucfoutu