473,324 Members | 2,501 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,324 software developers and data experts.

Array Function

Hi,

I am wondering how you multi-dimension an array function?

My declared function looks like this:

Public Function GetCustomerList(ByVal Val1 As String, ByVal Val2 As Long,
ByVal Val3 As String) As String()

Previously I dimensioned a single dimension Array to the size I wanted and
then just set the value of my function from this new Array.

Now I need to set a multi-dimension Array because I am reading more than one
record into the Array.

When I try to set the value of my function with the new muti-dimension Array
I get an error:

Value of type '2-dimensional array of String' cannot be converted to
'1-dimensional array of String' because the array types have different
numbers of dimensions.

Can anyone please provide assistance as to how to multi-dimension the
Function Array while still having the input parameters.

Thanks
Jan 6 '08 #1
9 2657
On Jan 5, 10:29*pm, Darkman <Dark...@discussions.microsoft.comwrote:
Hi,

I am wondering how you multi-dimension an array function?

My declared function looks like this:
Public Function GetCustomerList( _
ByVal Val1 As String, _
ByVal Val2 As Long, _
ByVal Val3 As String) As String(,)

HTH

--
Tom Shelton
Jan 6 '08 #2
Darkman,

You should not want to do this in 2008, in version 2005 there was already
the Generic List, which makes working with multidimensional arrays (lists)
much easier for you.

Cor
"Darkman" <Da*****@discussions.microsoft.comschreef in bericht
news:D9**********************************@microsof t.com...
Hi,

I am wondering how you multi-dimension an array function?

My declared function looks like this:

Public Function GetCustomerList(ByVal Val1 As String, ByVal Val2 As Long,
ByVal Val3 As String) As String()

Previously I dimensioned a single dimension Array to the size I wanted and
then just set the value of my function from this new Array.

Now I need to set a multi-dimension Array because I am reading more than
one
record into the Array.

When I try to set the value of my function with the new muti-dimension
Array
I get an error:

Value of type '2-dimensional array of String' cannot be converted to
'1-dimensional array of String' because the array types have different
numbers of dimensions.

Can anyone please provide assistance as to how to multi-dimension the
Function Array while still having the input parameters.

Thanks
Jan 6 '08 #3
On Jan 5, 11:47*pm, "Cor Ligthert[MVP]" <notmyfirstn...@planet.nl>
wrote:
Darkman,

You should not want to do this in 2008, in version 2005 there was already
the Generic List, which makes working with multidimensional arrays (lists)
much easier for you.

Cor

"Darkman" <Dark...@discussions.microsoft.comschreef in berichtnews:D9**********************************@m icrosoft.com...
Hi,
I am wondering how you multi-dimension an array function?
My declared function looks like this:
Public Function GetCustomerList(ByVal Val1 As String, ByVal Val2 As Long,
ByVal Val3 As String) As String()
Previously I dimensioned a single dimension Array to the size I wanted and
then just set the value of my function from this new Array.
Now I need to set a multi-dimension Array because I am reading more than
one
record into the Array.
When I try to set the value of my function with the new muti-dimension
Array
I get an error:
Value of type '2-dimensional array of String' cannot be converted to
'1-dimensional array of String' because the array types have different
numbers of dimensions.
Can anyone please provide assistance as to how to multi-dimension the
Function Array while still having the input parameters.
Thanks- Hide quoted text -

- Show quoted text -
Re-reading the what the OP said, I agree... I think this would be
more along the lines of something like:

Public Function GetCustomerList( _
ByVal Val1 As String, _
ByVal Val2 As Long, _
ByVal Val3 As String) As List(Of Customer)

Where customer is a custom buisness object containing the "record"
data.

--
Tom Shelton
Jan 6 '08 #4
"Darkman" <Da*****@discussions.microsoft.comschrieb
Hi,

I am wondering how you multi-dimension an array function?

My declared function looks like this:

Public Function GetCustomerList(ByVal Val1 As String, ByVal Val2 As
Long, ByVal Val3 As String) As String()

Previously I dimensioned a single dimension Array to the size I
wanted and then just set the value of my function from this new
Array.

Now I need to set a multi-dimension Array because I am reading more
than one record into the Array.

When I try to set the value of my function with the new
muti-dimension Array I get an error:

Value of type '2-dimensional array of String' cannot be converted to
'1-dimensional array of String' because the array types have
different numbers of dimensions.

Can anyone please provide assistance as to how to multi-dimension
the Function Array while still having the input parameters.
I'm not sure what you want. Which statement gives the error? What's the
declaration of the involved variables?
Armin

Jan 6 '08 #5
Let me explain further..

I have a DLL which I use to interact with the database. In the same project
I have a vb.net 2005 application which calls the DLL.

By adding the (,) as string the function in the DLL now compiles correctly.
However when I rebuild the DLL the function is not visible.

I have no idea about how to create a custom business object. This
application will never be upgraded to .net 2008 and I just need a quick fix.

Thanks
"Darkman" wrote:
Hi,

I am wondering how you multi-dimension an array function?

My declared function looks like this:

Public Function GetCustomerList(ByVal Val1 As String, ByVal Val2 As Long,
ByVal Val3 As String) As String()

Previously I dimensioned a single dimension Array to the size I wanted and
then just set the value of my function from this new Array.

Now I need to set a multi-dimension Array because I am reading more than one
record into the Array.

When I try to set the value of my function with the new muti-dimension Array
I get an error:

Value of type '2-dimensional array of String' cannot be converted to
'1-dimensional array of String' because the array types have different
numbers of dimensions.

Can anyone please provide assistance as to how to multi-dimension the
Function Array while still having the input parameters.

Thanks
Jan 6 '08 #6
On Jan 6, 1:06 pm, Darkman <Dark...@discussions.microsoft.comwrote:
Let me explain further..

I have a DLL which I use to interact with the database. In the same project
I have a vb.net 2005 application which calls the DLL.

By adding the (,) as string the function in the DLL now compiles correctly.
However when I rebuild the DLL the function is not visible.

I have no idea about how to create a custom business object. This
application will never be upgraded to .net 2008 and I just need a quick fix.

Thanks

"Darkman" wrote:
Hi,
I am wondering how you multi-dimension an array function?
My declared function looks like this:
Public Function GetCustomerList(ByVal Val1 As String, ByVal Val2 As Long,
ByVal Val3 As String) As String()
Previously I dimensioned a single dimension Array to the size I wanted and
then just set the value of my function from this new Array.
Now I need to set a multi-dimension Array because I am reading more than one
record into the Array.
When I try to set the value of my function with the new muti-dimension Array
I get an error:
Value of type '2-dimensional array of String' cannot be converted to
'1-dimensional array of String' because the array types have different
numbers of dimensions.
Can anyone please provide assistance as to how to multi-dimension the
Function Array while still having the input parameters.
Thanks
IIUC, you cannot see dll's function under your exe project. Right?
IMHO, the following reasons may cause this:

1-Incorrect usage of "imports" statement. Use imports for importing
correct library, namaespace.
(eg: imports system.text) and Use imports statement at the top of your
exe project code page. Even before, "Public Class".
2-Have referenced your library to your project? Right click -add
reference?
3-Always use "public" instead of private or else like you did.

I hope you solve the problem.

Hope this helps.
Jan 6 '08 #7
I can see my other functions within the DLL just fine.

I have declared this function as public.

It's only since adding the (,) As String in place of () As String that the
problem has occured:

Public Function GetCustomerList(ByVal Val1 As String, ByVal Val2 As Long) As
String(,)

Public Function GetCustomerList(ByVal Val1 As String, ByVal Val2 As Long) As
String()

"kimiraikkonen" wrote:
On Jan 6, 1:06 pm, Darkman <Dark...@discussions.microsoft.comwrote:
Let me explain further..

I have a DLL which I use to interact with the database. In the same project
I have a vb.net 2005 application which calls the DLL.

By adding the (,) as string the function in the DLL now compiles correctly.
However when I rebuild the DLL the function is not visible.

I have no idea about how to create a custom business object. This
application will never be upgraded to .net 2008 and I just need a quick fix.

Thanks

"Darkman" wrote:
Hi,
I am wondering how you multi-dimension an array function?
My declared function looks like this:
Public Function GetCustomerList(ByVal Val1 As String, ByVal Val2 As Long,
ByVal Val3 As String) As String()
Previously I dimensioned a single dimension Array to the size I wanted and
then just set the value of my function from this new Array.
Now I need to set a multi-dimension Array because I am reading more than one
record into the Array.
When I try to set the value of my function with the new muti-dimension Array
I get an error:
Value of type '2-dimensional array of String' cannot be converted to
'1-dimensional array of String' because the array types have different
numbers of dimensions.
Can anyone please provide assistance as to how to multi-dimension the
Function Array while still having the input parameters.
Thanks

IIUC, you cannot see dll's function under your exe project. Right?
IMHO, the following reasons may cause this:

1-Incorrect usage of "imports" statement. Use imports for importing
correct library, namaespace.
(eg: imports system.text) and Use imports statement at the top of your
exe project code page. Even before, "Public Class".
2-Have referenced your library to your project? Right click -add
reference?
3-Always use "public" instead of private or else like you did.

I hope you solve the problem.

Hope this helps.
Jan 6 '08 #8
On Jan 6, 2:02 pm, Darkman <Dark...@discussions.microsoft.comwrote:
I can see my other functions within the DLL just fine.

I have declared this function as public.

It's only since adding the (,) As String in place of () As String that the
problem has occured:

Public Function GetCustomerList(ByVal Val1 As String, ByVal Val2 As Long) As
String(,)

Public Function GetCustomerList(ByVal Val1 As String, ByVal Val2 As Long) As
String()

"kimiraikkonen" wrote:
On Jan 6, 1:06 pm, Darkman <Dark...@discussions.microsoft.comwrote:
Let me explain further..
I have a DLL which I use to interact with the database. In the same project
I have a vb.net 2005 application which calls the DLL.
By adding the (,) as string the function in the DLL now compiles correctly.
However when I rebuild the DLL the function is not visible.
I have no idea about how to create a custom business object. This
application will never be upgraded to .net 2008 and I just need a quick fix.
Thanks
"Darkman" wrote:
Hi,
I am wondering how you multi-dimension an array function?
My declared function looks like this:
Public Function GetCustomerList(ByVal Val1 As String, ByVal Val2 As Long,
ByVal Val3 As String) As String()
Previously I dimensioned a single dimension Array to the size I wanted and
then just set the value of my function from this new Array.
Now I need to set a multi-dimension Array because I am reading more than one
record into the Array.
When I try to set the value of my function with the new muti-dimension Array
I get an error:
Value of type '2-dimensional array of String' cannot be converted to
'1-dimensional array of String' because the array types have different
numbers of dimensions.
Can anyone please provide assistance as to how to multi-dimension the
Function Array while still having the input parameters.
Thanks
IIUC, you cannot see dll's function under your exe project. Right?
IMHO, the following reasons may cause this:
1-Incorrect usage of "imports" statement. Use imports for importing
correct library, namaespace.
(eg: imports system.text) and Use imports statement at the top of your
exe project code page. Even before, "Public Class".
2-Have referenced your library to your project? Right click -add
reference?
3-Always use "public" instead of private or else like you did.
I hope you solve the problem.
Hope this helps.
What does your function return with val1 and val2?

Here is an assumption:

I simulated something and assumed val1 is a customer name and val2 is
and customer ID (just an assumption, you didn't specified because).

Create a new form named "form1" and add these into your form:
(Here is customer name is "xyz" and "id" is 5000 as sample.)

Imports ClassLibrary1
Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim customers As New customerlist
MsgBox(customers.GetCustomerList("xyz ", 5000))

End Sub
End Class

Then add a class library into your project by going through file ->
add -new project -class library. Then reference the library by
right click -add reference -projects -your library name (i'd
suggest you to name your library as "Classlibrary1" in this sample).

Then put these into your library:

Option Explicit On

Public Class customerlist

Public Function GetCustomerList(ByVal Val1 As String, ByVal Val2
As Long) As String
Return Val1 & Val2
End Function
End Class

You should be able to get an result on form load inside a message box
as function returns customer name & ID.

Remember this sample was just an assumption and it depends on your
desire of course you can add another function returns.

Hope this helps.

Jan 6 '08 #9
Let me clarify.

I already have a function in the DLL called:

Public Function GetCustomer(ByVal Val1 As String, ByVal Val2 As Long) As
String()

This is a single dimension Array as it only returns the record for a single
customer. I can reference this function from the DLL fine.

I have a second function in the DLL called:

Public Function GetCustomerList(ByVal Val1 As String, ByVal Val2 As Long) As
String(,)

This is a multi-dimension Array because it returns multiple records. I
cannot see this function when I reference the Array. However if I remove the
"," which declares the function as a multi-dimension I CAN see the function
when I reference the DLL. (i.e.)

Public Function GetCustomerList(ByVal Val1 As String, ByVal Val2 As Long) As
String()

"kimiraikkonen" wrote:
On Jan 6, 2:02 pm, Darkman <Dark...@discussions.microsoft.comwrote:
I can see my other functions within the DLL just fine.

I have declared this function as public.

It's only since adding the (,) As String in place of () As String that the
problem has occured:

Public Function GetCustomerList(ByVal Val1 As String, ByVal Val2 As Long) As
String(,)

Public Function GetCustomerList(ByVal Val1 As String, ByVal Val2 As Long) As
String()

"kimiraikkonen" wrote:
On Jan 6, 1:06 pm, Darkman <Dark...@discussions.microsoft.comwrote:
Let me explain further..
I have a DLL which I use to interact with the database. In the same project
I have a vb.net 2005 application which calls the DLL.
By adding the (,) as string the function in the DLL now compiles correctly.
However when I rebuild the DLL the function is not visible.
I have no idea about how to create a custom business object. This
application will never be upgraded to .net 2008 and I just need a quick fix.
Thanks
"Darkman" wrote:
Hi,
I am wondering how you multi-dimension an array function?
My declared function looks like this:
Public Function GetCustomerList(ByVal Val1 As String, ByVal Val2 As Long,
ByVal Val3 As String) As String()
Previously I dimensioned a single dimension Array to the size I wanted and
then just set the value of my function from this new Array.
Now I need to set a multi-dimension Array because I am reading more than one
record into the Array.
When I try to set the value of my function with the new muti-dimension Array
I get an error:
Value of type '2-dimensional array of String' cannot be converted to
'1-dimensional array of String' because the array types have different
numbers of dimensions.
Can anyone please provide assistance as to how to multi-dimension the
Function Array while still having the input parameters.
Thanks
IIUC, you cannot see dll's function under your exe project. Right?
IMHO, the following reasons may cause this:
1-Incorrect usage of "imports" statement. Use imports for importing
correct library, namaespace.
(eg: imports system.text) and Use imports statement at the top of your
exe project code page. Even before, "Public Class".
2-Have referenced your library to your project? Right click -add
reference?
3-Always use "public" instead of private or else like you did.
I hope you solve the problem.
Hope this helps.

What does your function return with val1 and val2?

Here is an assumption:

I simulated something and assumed val1 is a customer name and val2 is
and customer ID (just an assumption, you didn't specified because).

Create a new form named "form1" and add these into your form:
(Here is customer name is "xyz" and "id" is 5000 as sample.)

Imports ClassLibrary1
Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim customers As New customerlist
MsgBox(customers.GetCustomerList("xyz ", 5000))

End Sub
End Class

Then add a class library into your project by going through file ->
add -new project -class library. Then reference the library by
right click -add reference -projects -your library name (i'd
suggest you to name your library as "Classlibrary1" in this sample).

Then put these into your library:

Option Explicit On

Public Class customerlist

Public Function GetCustomerList(ByVal Val1 As String, ByVal Val2
As Long) As String
Return Val1 & Val2
End Function
End Class

You should be able to get an result on form load inside a message box
as function returns customer name & ID.

Remember this sample was just an assumption and it depends on your
desire of course you can add another function returns.

Hope this helps.

Jan 6 '08 #10

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

Similar topics

58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
11
by: deko | last post by:
I need to create a basic one-dimensional array of strings, but I don't know how many strings I'm going to have until the code is finished looping. pseudo code: Dim astrMyArray() Do While Not...
8
by: Tweaxor | last post by:
Hey, I was trying to figure out was it possible in C to pass the values in an array from one function to another function. Is the possible in C? ex. y is the array that holds seven values If...
6
by: Herrcho | last post by:
in K&R Chapter 6.3 it mentions two methods to calculate NKEYS. and points out the first one which is to terminate the list of initializers with a null pointer, then loop along keytab until the...
7
by: Jim Carlock | last post by:
Looking for suggestions on how to handle bad words that might get passed in through $_GET variables. My first thoughts included using str_replace() to strip out such content, but then one ends...
4
by: assgar | last post by:
Hi Seasons Greetings Its back, I am being haunted. I thought I had resolved this problem but I am intermittently the receving the warnings below. This code consist of a 1) HTML form, 2)...
14
by: Abhi | last post by:
I wrote a function foo(int arr) and its prototype is declared as foo(int arr); I modify the values of the array in the function and the values are getting modified in the main array which is...
7
by: bowlderster | last post by:
Hello,all. I want to get the array size in a function, and the array is an argument of the function. I try the following code. /*************************************** */ #include<stdio.h>...
26
by: aruna.mysore | last post by:
Hi all, I have a specific problem passing a function pointer array as a parameter to a function. I am trying to use a function which takes a function pointer array as an argument. I am too sure...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.