Est-il possible de retourner un tableau avec une fonction ??
cs_enzino
Messages postés8Date d'inscriptionlundi 4 février 2002StatutMembreDernière intervention 4 juin 2003
-
6 mai 2003 à 14:04
stevebelgium
Messages postés180Date d'inscriptionlundi 17 mars 2003StatutMembreDernière intervention 7 juin 2003
-
6 mai 2003 à 15:05
Bonjour,
Je reviens avec mon problème de Fonction !!!
Je me suis fait mal comprendre lors de ma première question.
La question est : Est-il possible avec une fonction de retourner un tableau ???
Je vais vous détaillé mon problème.
Je lis dans un fichier toutes les lignes que je stock dans une variable "TextLine"
ex:
SEQUENCE Integer
NO_PARCELLE Char(10)
etc ....
Après cette variable j'aimerai la diriger vers une fonction qui va me spliter cette ligne dans un
tableau.
ex: résultat souhaité
TabChamps(1,1) = SEQUENCE
TabChamps(1,2) = Integer
Do While Not EOF(1) ' Effectue la boucle jusqu'à la fin du fichier.
Line Input #1, TextLine ' Lit la ligne dans la variable.
j = j + 1
ReDim TabChamps(j)
TabChamps(j) = FctSplitAttribut(Trim(TextLine)) ************ PROBLEME ***********
' rempli la listebox
Form1.Lst_ChoixAttribut.AddItem TabChamps(j)
Loop
Close #1
End sub
*******************************************************************************
'Ets-il possible que la fonction "FctSplitAttribut" me retourne un tableau ????
Public Function FctSplitAttribut(TextLine)
Dim TabListChamps() As String
Dim a As Integer
Dim Separateur As String
For a = LBound(TabListChamps) To UBound(TabListChamps)
FctSplitAttribut = TabListChamps(a) !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Next
End Function
Dim TabChamps() As String
Dim x, y As Integer
Dim Temp As String
x = 0
Temp = ""
Open "c:\a.txt" For Input As #1
Do Until EOF(1)
Line Input #1, Temp
y = y + 1
Loop
Close #1
Open "c:\a.txt" For Input As #1
ReDim Preserve TabChamps(y - 1, 1)
Do Until EOF(1)
Line Input #1, Temp
x = x + 1
TabChamps(x - 1, 0) = Left(Temp, InStr(1, Temp, " "))
TabChamps(x - 1, 1) = Mid(Temp, InStr(1, Temp, " "))
Loop
Close #1
For x = 0 To UBound(TabChamps())
MsgBox "TabChamps(" & x & ",1) = " & TabChamps(x, 0) & Chr$(13) & _
"TabChamps(" & x & ",2) = " & TabChamps(x, 1)
Next x