probleme Textbox

dran_200

XLDnaute Occasionnel
Bonjour à tous,
J'ai un soucis pour charger des valeurs dans des textbox. Pour 10 textbox j'ai ce lien :
ListBox2.AddItem
ListBox2.List(ListBox2.ListCount - 1, 0) = Cell.Offset(, 2)
ListBox2.List(ListBox2.ListCount - 1, 1) = Cell.Offset(, 4)
ListBox2.List(ListBox2.ListCount - 1, 2) = Cell.Offset(, 0)
ListBox2.List(ListBox2.ListCount - 1, 3) = Cell.Offset(, 8)
ListBox2.List(ListBox2.ListCount - 1, 4) = Cell.Offset(, 9)
ListBox2.List(ListBox2.ListCount - 1, 5) = Cell.Offset(, 10)
ListBox2.List(ListBox2.ListCount - 1, 6) = Cell.Offset(, 11)
ListBox2.List(ListBox2.ListCount - 1, 7) = Cell.Offset(, 6)
ListBox2.List(ListBox2.ListCount - 1, 8) = Cell.Offset(, 7)
ListBox2.List(ListBox2.ListCount - 1, 9) = Cell.Offset(, 5)
je charge mes textbox avec :
TextBox2 = ListBox2.List(ListBox2.ListIndex, 1)
etc.....
Jusque la tout fonctionne, le probleme est que j'ai besoin de créer plus de texbox et que le chemin ne fonctionne pas pour plus de 10 textbox :
ListBox2.List(ListBox2.ListCount - 1, 10) = Cell.Offset(, 5)
ça plante sur la valeur "10" ou plus !!!!
comment faire ?
merci pour votre aide
 

abtony

XLDnaute Impliqué
Re : probleme Textbox

Bonjour laetitia90, dran_200, le forum,

Laetitia, pour mon apprentissage, peux tu m'expliquer cette partie du code.

Pourquoi cette question ? tout simplement parceque ça fonctionne sous excel mac 2011 sans erreur, mais la combobox ne se remplis pas, alors que sous excel 2003 sous windows pas de problème.

Je soupçonne que le problème viens de la ligne en rouge.
Peut être non reconnu encore, comme LoadImage.

D'ailleur LoadImage ne semble pas fonctionner du tout sur mon Imac, que ce soit avec windows ou snow leopard.

Code:
Private Sub UserForm_Initialize()
Dim t, z As Variant, l As Object, i As Long, j As Long, temp As String
On Error Resume Next
Set l = [COLOR="Red"]CreateObject("Scripting.Dictionary")[/COLOR]
t = Range("a2", Cells(Rows.Count, "a").End(xlUp))
For i = LBound(t) To UBound(t)
l.Add t(i, 1), t(i, 1): Next
For Each z In l
If z <> "" Then cbx1.AddItem z
cbx1.ListIndex = 0: Next
For i = 0 To cbx1.ListCount - 1
For j = 0 To cbx1.ListCount - 1
If cbx1.List(i) < cbx1.List(j) Then
temp = cbx1.List(i)
cbx1.List(i) = cbx1.List(j)
cbx1.List(j) = temp
End If: Next j: Next i
cbx1.ListIndex = -1
ListBox2.Visible = False
ListBox2.Clear: ListBox3.Clear
End Sub

le but est de voir la compatibilité avec excel mac.

Merci d'avance pour votre aide.

A+

Edit: Common controls 6 n'existe pas encore sous mac, voila pourquoi.
Comment on peux modifier cette ligne, par quoi ?
Merci
 
Dernière édition:

laetitia90

XLDnaute Barbatruc
Re : probleme Textbox

bonjour tous
pour l'ami abtony si l'object Dictionary ne passe pas tu essaye une collection
attention quand meme avec certaines donnees pas le resultat desire puis plus lent

Code:
Sub est()
Dim t, z As Variant, l As Collection, i As Long, j As Long, temp As String
On Error Resume Next
Set l = New Collection
t = Range("a2", Cells(Rows.Count, "a").End(xlUp))
For i = LBound(t) To UBound(t)
l.Add t(i, 1), t(i, 1): Next
For Each z In l
cbx1.AddItem z: Next
For i = 0 To cbx1.ListCount - 1
For j = 0 To cbx1.ListCount - 1
If cbx1.List(i) < cbx1.List(j) Then
temp = cbx1.List(i)
cbx1.List(i) = cbx1.List(j)
cbx1.List(j) = temp
End If: Next j: Next i
End Sub

si la collection passe pas non plus boucle classique

Code:
Sub es()
Dim c As Range, i As Long, j As Long, temp As String
  For Each c In Range("a2", Cells(Rows.Count, "a").End(xlUp))
   cbx1 = c
    If cbx1.ListIndex = -1 And cbx1 <> "" Then cbx1.AddItem c
  Next c
  For i = 0 To cbx1.ListCount - 1
  For j = 0 To cbx1.ListCount - 1
   If cbx1.List(i) < cbx1.List(j) Then
    temp = cbx1.List(i)
    cbx1.List(i) = cbx1.List(j)
   cbx1.List(j) = temp
   End If: Next j: Next i
     End Sub

d'aillers dans mon code avec Dictionary 2 erreurs variable declare 2 fois +cbx1.ListIndex = -1 apres cbx1.AddItem z sert a rien trop vite fait:(
 

abtony

XLDnaute Impliqué
Re : probleme Textbox

Bonjour laetitia,

New Collection passe sous mac, et c'est aussi rapide.

Je ne sais pas si sur la version finale, ils vont rajouter des références supplémentaires

tel que

Control Piker
LoadImage (qui ne semble pas fonctionner du tout) que ce soit sur mac ou sous windows sur mon Imac ?

on vera ca a la sortie de la version finale, courant octobre de cette année.

Merci a toi laetitia

Amicalement
 
Dernière édition:

Discussions similaires

Réponses
4
Affichages
253
Réponses
17
Affichages
994
Réponses
15
Affichages
578