473,382 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Newby question: How do you handles arrays with functions?

Just some basic questions because none of my reference manuals cover
this explicitly:

1) If you want have an argument as an array of integers would this
be the correct declaration?

Function foo(bar() as Integer) as Integer
...
End Function

2) If you wanted to *return* an array of integers from the function
would this declaration be correct?

Function foo(bar as Integer) as Integer()
...
End Function

TIA...

Dec 12 '05 #1
3 1141
Blue Streak,

Yep, you've got it.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Blue Streak" <rd********@hotmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Just some basic questions because none of my reference manuals cover
this explicitly:

1) If you want have an argument as an array of integers would this
be the correct declaration?

Function foo(bar() as Integer) as Integer
...
End Function

2) If you wanted to *return* an array of integers from the function
would this declaration be correct?

Function foo(bar as Integer) as Integer()
...
End Function

TIA...

Dec 12 '05 #2
Since you went to the trouble of writing it out here, you could have simply
tried it out. Your code looks fine, except I think () should come after
integer not bar in the 1st example

For the parameters, you could declare it as ParamArray which would let you
pass in 1 value, great replacement for overloading (in some cases)

Function foo (ParamArray bar as integer()

end function

you can now call foo with either a single value, or an array, or a comma
separated list

foo(1)
foo(arr)
foo(1,2,3,4,5)

ParramArray _must_ be the last parameter of a function.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Blue Streak" <rd********@hotmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Just some basic questions because none of my reference manuals cover
this explicitly:

1) If you want have an argument as an array of integers would this
be the correct declaration?

Function foo(bar() as Integer) as Integer
...
End Function

2) If you wanted to *return* an array of integers from the function
would this declaration be correct?

Function foo(bar as Integer) as Integer()
...
End Function

TIA...

Dec 12 '05 #3
Karl,

In VB.NET the parentheses may be placed just after the parameter name or
after the type declaration. It's up to the developer, but both ways work.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2***************@TK2MSFTNGP10.phx.gbl...
Since you went to the trouble of writing it out here, you could have
simply tried it out. Your code looks fine, except I think () should come
after integer not bar in the 1st example

For the parameters, you could declare it as ParamArray which would let
you pass in 1 value, great replacement for overloading (in some cases)

Function foo (ParamArray bar as integer()

end function

you can now call foo with either a single value, or an array, or a comma
separated list

foo(1)
foo(arr)
foo(1,2,3,4,5)

ParramArray _must_ be the last parameter of a function.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Blue Streak" <rd********@hotmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Just some basic questions because none of my reference manuals cover
this explicitly:

1) If you want have an argument as an array of integers would this
be the correct declaration?

Function foo(bar() as Integer) as Integer
...
End Function

2) If you wanted to *return* an array of integers from the function
would this declaration be correct?

Function foo(bar as Integer) as Integer()
...
End Function

TIA...


Dec 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: csx | last post by:
Hi everyone! two quick questions relating to arrays. Q1, Is it possible to re-assign array elements? int array = {{2,4}, {4,5}}; array = {2,3}
9
by: CeyloR | last post by:
Hello everyone, I just started with the language C and it's very interesting. I bought the book 'The C Programming Language' from Brian W. Kernighan and Dennis M. Ritchie. While reading...
7
by: Fred Nelson | last post by:
Hi: I'm more than a little confused with this question: I need to create a char type from the first letter in a string - for example: string mystring; char mychar;
10
by: Fred Nelson | last post by:
Hi: I have programmed in VB.NET for about a year and I'm in the process of learing C#. I'm really stuck on this question - and I know it's a "newby" question: In VB.NET I have several...
4
by: Chris | last post by:
Hi, are managed arrays of value types created on the managed heap, just as are managed arrays of reference types ? String* StrArray = new String* ; // Arrays of a Reference type int...
12
by: Peter | last post by:
I'm looking to create multiple textboxs that change to a light blue on focus. What is the most efficient way to do this? -Peter
2
by: Len via DotNetMonster.com | last post by:
I have to set up a 2d array(13, 4) containing a deck of playing cards. What I am wondering is how to correctly set up the array in the first place, and then how do you access the information once...
4
by: Boni | last post by:
Hi, How do I create an array of 2 to object pointers? i.e. dim a as object(2) Thanks, Boni
21
by: yeti349 | last post by:
Hi, I'm using the following code to retrieve data from an xml file and populate a javascript array. The data is then displayed in html table form. I would like to then be able to sort by each...
5
by: alexrixhardson | last post by:
Hi guys, I am a newby in the C/C++ world, and I am beginning to work on a rather simple TCP/IP proxy application which must be able to handle large volume of data as quickly as possible. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.