 |

11-20-2005, 09:20 AM
|
 |
Regular
|
|
Join Date: May 2003
Location: South Africa
Posts: 63
|
|
Passing array as literal
|
lets say ive got this (for the sake of argument)
Code:
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:
Code:
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
|
|

11-20-2005, 09:40 AM
|
 |
Ultimate Contributor
Retired Leader * Guru *
|
|
Join Date: Aug 2001
Posts: 5,343
|
|
|
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.
|
|

11-20-2005, 09:43 AM
|
 |
Regular
|
|
Join Date: May 2003
Location: South Africa
Posts: 63
|
|
Quote:
|
Originally Posted by Volte
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./
|
|

11-20-2005, 09:47 AM
|
 |
Ultimate Contributor
Retired Leader * Guru *
|
|
Join Date: Aug 2001
Posts: 5,343
|
|
|
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.
|
|

11-20-2005, 09:51 AM
|
 |
Regular
|
|
Join Date: May 2003
Location: South Africa
Posts: 63
|
|
|
thankyou,
Ill see what i can do.
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|