469,636 Members | 1,555 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,636 developers. It's quick & easy.

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 2485
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Tweaxor | last post: by
7 posts views Thread by Jim Carlock | last post: by
4 posts views Thread by assgar | last post: by
14 posts views Thread by Abhi | last post: by
26 posts views Thread by aruna.mysore | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.