Traitement de chaine

Résolu
BeinMoi Messages postés 16 Date d'inscription mardi 21 décembre 2004 Statut Membre Dernière intervention 21 octobre 2005 - 29 août 2005 à 13:57
cs_CanisLupus Messages postés 3757 Date d'inscription mardi 23 septembre 2003 Statut Membre Dernière intervention 13 mars 2006 - 29 août 2005 à 15:48
Salut a tous,

Eh voila j'essai de faire un tri d'une chaine de caratere contenant des noms de fichiers separes par une virgule, de maniere a placer chaque fichiers ds un tableau....

Quelqu'un saurait il me dire ou est l'erreur(s) ds mon code :

Dim NbChr As Long
Dim SepStrng As String
Dim Txt As String
Dim File(1 To 100) As String
Dim Occ1 As Long
Dim Occ2 As Long
Dim i As Long
Dim Ii As Long


Occ1 = 1
Txt = Text1.Text
NbChr = Len(Txt)
SepStrng = ","

Do
i = i + 1
Occ2 = InStr(Occ1, Txt, SepStrng) If Occ2 0 Then File(i) Mid(Txt, Occ1, NbChr): Exit Do
File(i) = Mid(Txt, Occ1, Occ2 - 1)
Occ1 = Occ1 + Len(File(i))
Loop


For Ii = 1 To i
MsgBox File(Ii)
Next Ii

Merci d'avance @+

3 réponses

EddiePonpon Messages postés 33 Date d'inscription mardi 15 juillet 2003 Statut Membre Dernière intervention 31 août 2005
29 août 2005 à 14:13
Comme ça Apparement, ça marche

Do
i = i + 1
Occ2 = InStr(Occ1, Txt, SepStrng)
If Occ2 0 Then File(i) Mid(Txt, Occ1, NbChr): Exit Do
File(i) = Mid(Txt, Occ1, Occ2 - Occ1)
Occ1 = Occ2 + 1
Loop
3
BeinMoi Messages postés 16 Date d'inscription mardi 21 décembre 2004 Statut Membre Dernière intervention 21 octobre 2005
29 août 2005 à 14:17
Super merci EddiePonpon c'est impec ;)

Bonne prog a tous @+
0
cs_CanisLupus Messages postés 3757 Date d'inscription mardi 23 septembre 2003 Statut Membre Dernière intervention 13 mars 2006 20
29 août 2005 à 15:48
Salut, si c'est du vb6, tu aurais pu faire :

Dim file() as string
Dim Ii As Long

file = split(text1.text,",")

For Ii = 0 To ubound(file)
MsgBox File(Ii)
Next Ii

-------------------------------------------------
Dresseur de puces, .... normal pour un loup !?
0
Rejoignez-nous