listbox et msgbox

  • Initiateur de la discussion damien
  • Date de début
D

damien

Guest
bonsoir le forum

j'ai un textbox1 et une listbox1

je voudrai que si mon textbox1 est rempli et ma listbox1 vide il me renvoi un msgbox.

j'ai fais
if textbox1>'' and listbox1.value =null then msgbox 'veuiller changer de valeur'


mais ça ne marche pas
merci pour votre aide
damien
 
D

damien

Guest
bonjour à vous.
ça ne marche pas.

merci pour votre aide
dam
voici macro
Private Sub TextBox1_Change()
TextBox1 = UCase(TextBox1)

Dim c As Range, lig As Range
Dim x As Long

With ListBox1
.Clear
.IntegralHeight = True
.Visible = True
.ColumnCount = 10
.ColumnWidths = '70;150;50;80;110;50;150;100;50;05'

For Each lig In Worksheets('liste').UsedRange.Rows
If Left(lig.Cells(2), Len(TextBox1)) = TextBox1 Then
.AddItem lig.Cells(1).Text

.List(x, 1) = lig.Cells(2).Text 'nom
.List(x, 2) = lig.Cells(3).Text 'lht
.List(x, 3) = lig.Cells(5).Text 'port d'attache
.List(x, 4) = lig.Cells(6).Text 'pavillon
.List(x, 5) = lig.Cells(7).Text ' callsign
.List(x, 6) = lig.Cells(8).Text 'type
.List(x, 7) = lig.Cells(10).Text
.List(x, 8) = lig.Cells(11).Text
.List(x, 9) = lig.Row
x = x + 1
If TextBox1 = '' Then
Exit Sub
ListBox1.Visible = False
End If


End If
Next lig
End With

End Sub
 

MichelXld

XLDnaute Barbatruc
bonsoir Damien , bonsoir Luc

ça ne marche pas.

peux tu préciser :
tu as un message d'erreur ?
lequel ?
à quelle ligne ?


à tout hasard ...

Private Sub TextBox1_Change()
Dim c As Range, lig As Range
Dim x As Long

If Not Len(TextBox1) = 0 And ListBox1.ListIndex = -1 Then
MsgBox 'veuiller changer de valeur'
Exit Sub
End If


TextBox1 = UCase(TextBox1)

With ListBox1
.Clear
.IntegralHeight = True
.Visible = True
.ColumnCount = 10
.ColumnWidths = '70;150;50;80;110;50;150;100;50;05'

For Each lig In Worksheets('liste').UsedRange.Rows
If Left(lig.Cells(2), Len(TextBox1)) = TextBox1 Then
.AddItem lig.Cells(1).Text

.List(x, 1) = lig.Cells(2).Text 'nom
.List(x, 2) = lig.Cells(3).Text 'lht
.List(x, 3) = lig.Cells(5).Text 'port d'attache
.List(x, 4) = lig.Cells(6).Text 'pavillon
.List(x, 5) = lig.Cells(7).Text ' callsign
.List(x, 6) = lig.Cells(8).Text 'type
.List(x, 7) = lig.Cells(10).Text
.List(x, 8) = lig.Cells(11).Text
.List(x, 9) = lig.Row
x = x + 1
If TextBox1 = '' Then
Exit Sub
ListBox1.Visible = False
End If


End If
Next lig
End With

End Sub


bonne soirée
MichelXld
 

Discussions similaires

Réponses
17
Affichages
851

Statistiques des forums

Discussions
312 338
Messages
2 087 396
Membres
103 534
dernier inscrit
Kalamymustapha