473,695 Members | 2,389 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2681
On Jan 5, 10:29*pm, Darkman <Dark...@discus sions.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 multidimensiona l arrays (lists)
much easier for you.

Cor
"Darkman" <Da*****@discus sions.microsoft .comschreef in bericht
news:D9******** *************** ***********@mic rosoft.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 multidimensiona l arrays (lists)
much easier for you.

Cor

"Darkman" <Dark...@discus sions.microsoft .comschreef in berichtnews:D9* *************** *************** ***@microsoft.c om...
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*****@discus sions.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...@discus sions.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()

"kimiraikko nen" wrote:
On Jan 6, 1:06 pm, Darkman <Dark...@discus sions.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...@discus sions.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()

"kimiraikko nen" wrote:
On Jan 6, 1:06 pm, Darkman <Dark...@discus sions.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(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim customers As New customerlist
MsgBox(customer s.GetCustomerLi st("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 "Classlibra ry1" 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(ByV al 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()

"kimiraikko nen" wrote:
On Jan 6, 2:02 pm, Darkman <Dark...@discus sions.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()

"kimiraikko nen" wrote:
On Jan 6, 1:06 pm, Darkman <Dark...@discus sions.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(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim customers As New customerlist
MsgBox(customer s.GetCustomerLi st("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 "Classlibra ry1" 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
10138
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 code... TCHAR myArray; DoStuff(myArray);
11
39462
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 rst.EOF i = i + 1 If rst!Something = Then astrMyArray(i) = rst!Something
8
29052
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 possible how could one pass these seven values in the array to a function that would check the values. I tried return y but it didn't work
6
4145
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 end is found is less efficient than using sizeof operator , since size of the array is completely determined at compile time. i don't quite understand this. Could anyone explain to me in detail ?
7
3195
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 up looking for characters that wrap around the stripped characters and it ends up as a recursive ordeal that fails to identify a poorly constructed $_GET variable (when someone hand-types the item into the line and makes a simple typing error).
4
1980
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) a display function on the HTML form and
14
20393
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 passed also. I understand that this way of passing the array is by value and if the prototype is declared as foo(int *), it is by reference in which case the value if modified in the function will get reflected in the main function as well. I dont...
7
8129
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> #include<stdlib.h> #include<math.h>
26
4860
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 about the syntax of calling the same. #include <stdio.h> void fp1()
0
8572
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8984
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8847
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7661
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6491
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5839
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4340
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3003
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
1976
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.