Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is there a way to pass an array into a function or Sub?
Message
 
À
26/03/2001 14:16:22
Information générale
Forum:
Visual Basic
Catégorie:
Autre
Divers
Thread ID:
00488646
Message ID:
00488667
Vues:
8
Try adding () to the arg declaration as below:
private sub ProcessArray(MyArray() as String)
  dim i%
  for i = 0 to UBound(MyArray)
    MyArray(i) = i
  next
end sub
>How would I pass an array into a function like any other data type?
>When I try:
>
>private sub ProcessArray(MyArray as Array)
> dim i%
> for i = 0 to UBound(MyArray)
> MyArray(i) = i
> next
>end sub
>
>I get an error because the compiler is expecting values after the keyword "Array".
>
>I tried this as a variant like:
>
>private sub ProcessArray(MyArray as variant)
> dim i%
> for i = 0 to UBound(MyArray)
> MyArray(i) = i
> next
>end sub
>
>But during runtime I error out on the UBound(MyArray) call because of an invalid type argument. It appears that when I pass the original array in which is an array of strings, the variant type in the function is assumed to be just a string value and not an array of strings.
>
>Can anyone help me please? Thanks.
Roi
'MCP' Visual FoxPro

In Rome, there was a poem.
About a dog, who found two bone.
He lick the one, he lick the other.
He went pyscho, he drop dead!
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform