Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Passing array as literal


Reply
 
Thread Tools Display Modes
  #1  
Old 11-20-2005, 09:20 AM
dve83's Avatar
dve83 dve83 is offline
Regular
 
Join Date: May 2003
Location: South Africa
Posts: 63
Default 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
Reply With Quote
  #2  
Old 11-20-2005, 09:40 AM
Volte's Avatar
Volte Volte is offline
Ultimate Contributor

Retired Leader
* Guru *
 
Join Date: Aug 2001
Posts: 5,343
Default

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.
Reply With Quote
  #3  
Old 11-20-2005, 09:43 AM
dve83's Avatar
dve83 dve83 is offline
Regular
 
Join Date: May 2003
Location: South Africa
Posts: 63
Default

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./
Reply With Quote
  #4  
Old 11-20-2005, 09:47 AM
Volte's Avatar
Volte Volte is offline
Ultimate Contributor

Retired Leader
* Guru *
 
Join Date: Aug 2001
Posts: 5,343
Default

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.
Reply With Quote
  #5  
Old 11-20-2005, 09:51 AM
dve83's Avatar
dve83 dve83 is offline
Regular
 
Join Date: May 2003
Location: South Africa
Posts: 63
Default

thankyou,
Ill see what i can do.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->