Page 1 sur 1

syntaxe

MessagePublié: 14 Août 2003 à 13:44
par polo
est-il possible de faire une fonction LS, qui retourne une liste de chaine ?LS me refuse cette déclaration :Function ExplodeString(Code As String,separateur As String) List As String

Re: syntaxe

MessagePublié: 14 Août 2003 à 14:13
par Droad
un p'tit agent qui montre quelques possibilités (et pourquoi une list ? un tableau semble + approprié):Sub Initialize Dim i As Integer Dim list1 list1 = aList() Print "LIST2:" Forall e1 In list1 Print Listtag(e1) & " = " & e1 End Forall Dim list2 List As String Call aListUpdater(list2) Print "LIST2:" Forall e2 In list2 Print Listtag(e2) & " = " & e2 End Forall Print "ARRAY1:" Dim arr1 As Variant arr1 = anArray() For i=0 To Ubound(arr1) Print i & " = " & arr1(i) Next Print "ARRAY2:" Redim arr2(0) As String Call anArrayUpdater(arr2) For i=0 To Ubound(arr2) Print i & " = " & arr2(i) NextEnd SubFunction aList() As Variant Dim l List As String l("A") = "aaaa" l("B") = "bbbb" aList = lEnd FunctionSub aListUpdater(res List As String) res("Z") = "zzzz" res("Y") = "yyyy"End SubFunction anArray() As Variant Dim result(2) As String result(0) = "zero" result(1) = "un" result(2) = "deux" anArray = resultEnd FunctionSub anArrayUpdater(arr() As String) Redim arr(2) arr(0) = "ZZ" arr(1) = "UU" arr(2) = "DD"End SubRem: si tu es en v6, il y a une fonction StrToken qui fait ça.[%sig%]

Re: syntaxe

MessagePublié: 14 Août 2003 à 14:39
par polo
merci !