Passing array as literal

dve83
11-20-2005, 10:20 AM
lets say ive got this (for the sake of argument)


public function getdata(names() as string) as string

label.caption = names(1)

end function


lets say I want to call this function and send it an undetermined number of values for the array. : I thought Id changer the header so it has a "number" parameter as well and the redim the array in the function body. like so:


public function getdata(number as integer,names() as string)
redim names(number)
end function


any thoughts?

ok second (and actual question): If I want to call this function, how can I send the data to the formal array parameter without sending another array? Is their some way in which i can send the data as literals?

thanks so long
dve83

Volte
11-20-2005, 10:40 AM
Well as for the first part of your post, you didn't really ask any questions. If you just want to know if it will work, then yes it will. As for the second, I'm not clear on what you mean. If you mean send the array all on one line, such as { "item1", "item2", "item3" } as in C++, then no, VB does not support that.

dve83
11-20-2005, 10:43 AM
Well as for the first part of your post, you didn't really ask any questions. If you just want to know if it will work, then yes it will. As for the second, I'm not clear on what you mean. If you mean send the array all on one line, such as { "item1", "item2", "item3" } as in C++, then no, VB does not support that.


ah.... :-( any alternatives?

btw, thanks for the quick reply./

Volte
11-20-2005, 10:47 AM
Yes, set the array items individually.

You can also use the Array() function which acts sort of like the C++ array declarator, but it returns variants and so I tend to avoid it in most cases.

dve83
11-20-2005, 10:51 AM
thankyou,
Ill see what i can do.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum