473,513 Members | 2,270 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

passing an array to a module

this is what I have

'variables defined as arrays

Dim ceday(), ceti(), ceto(), ceproj(), cenotes() As String

Dim cerow As Int32

Private Sub cboEmpName_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
cboEmpName.SelectedIndexChanged

Dim ename As String

cerow = 2

ename = cboEmpName.SelectedItem

EditInfo(ename, cerow, ceday(), ceti(), ceto(),ceproj () , cenotes())

'finish doing stuff

End Sub

'in another module

Public Sub EditInfo(ByVal empname As String, ByRef i As Int16, ByRef
ceday() As Array, ByRef ceti() As Array, ByRef ceto() As Array, ByRef
ceproj() As Array, ByRef cenotes() As Array)

'do stuff

i = XLObj.activesheet.Cells(1,1).currentregion.rows.co unt

ReDim ceday(i), ceti(i), ceto(i), ceproj(i), cenotes(i)

'do more stuff

End Sub

the arrays in Private Sub cboEmpName_SelectedIndexChanged have the ()
underlined in blue and the message is:
Number of indicies is less than the number of dimensions of the indexed
array.

Since these are all one dimension arrays I do not understand why this
error is showing up.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #1
4 1667
Your method EditInfo is expecting an array of Arrays while you are passing
in an array of strings. Change the definition of your method to:

Public Sub EditInfo(ByVal empname As String, ByRef i As Int16, _
ByRef ceday() As String, ByRef ceti() As String, _
ByRef ceto() As String, ByRef ceproj() As String, _
ByRef cenotes() As String)

Alternatively, you could also change it to:
Public Sub EditInfo(ByVal empname As String, ByRef i As Int16, _
ByRef ceday As Array, ByRef ceti As Array, _
ByRef ceto As Array, ByRef ceproj As Array, _
ByRef cenotes As Array)

Personally, I would go with the first one.

hope that helps..
Imran.

this is what I have

'variables defined as arrays

Dim ceday(), ceti(), ceto(), ceproj(), cenotes() As String

Dim cerow As Int32

Private Sub cboEmpName_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
cboEmpName.SelectedIndexChanged

Dim ename As String

cerow = 2

ename = cboEmpName.SelectedItem

EditInfo(ename, cerow, ceday(), ceti(), ceto(),ceproj () ,
cenotes())

'finish doing stuff

End Sub

'in another module

Public Sub EditInfo(ByVal empname As String, ByRef i As Int16, ByRef
ceday() As Array, ByRef ceti() As Array, ByRef ceto() As Array, ByRef
ceproj() As Array, ByRef cenotes() As Array)

'do stuff

i = XLObj.activesheet.Cells(1,1).currentregion.rows.co unt

ReDim ceday(i), ceti(i), ceto(i), ceproj(i), cenotes(i)

'do more stuff

End Sub

the arrays in Private Sub cboEmpName_SelectedIndexChanged have the ()
underlined in blue and the message is:
Number of indicies is less than the number of dimensions of the
indexed
array.
Since these are all one dimension arrays I do not understand why this
error is showing up.

*** Sent via Developersdex http://www.developersdex.com *** Don't just
participate in USENET...get rewarded for it!


Nov 21 '05 #2
both options produce the same effect for me as what I had expressed
before. It says:
Number if indicies is less than the number of dimensions of the indexed
array.

Public Sub EditInfo(ByVal empname As String, ByRef i As Int16, ByRef
ceday() As String, ByRef ceti() As String, ByRef ceto() As String, ByRef
ceproj() As String, ByRef cenotes() As String, ByRef ceworked() As
String)
is what i have here now. the little blue line is under the () in the
line

EditInfo(ename, cerow, ceday(), ceti(), ceto(), ceproj(), cenotes(),
ceworked())

and when I hover the mouse over the () the message appears in the tool
tip box.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #3
Erik,
Have you tried:

EditInfo(ename, cerow, ceday, ceti, ceto, ceproj, _
cenotes, ceworked)

Note there are no () when you pass an array as a parameter.

Hope this helps
Jay

"Erik Foreman" <Er**@devedx.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
both options produce the same effect for me as what I had expressed
before. It says:
Number if indicies is less than the number of dimensions of the indexed
array.

Public Sub EditInfo(ByVal empname As String, ByRef i As Int16, ByRef
ceday() As String, ByRef ceti() As String, ByRef ceto() As String, ByRef
ceproj() As String, ByRef cenotes() As String, ByRef ceworked() As
String)
is what i have here now. the little blue line is under the () in the
line

EditInfo(ename, cerow, ceday(), ceti(), ceto(), ceproj(), cenotes(),
ceworked())

and when I hover the mouse over the () the message appears in the tool
tip box.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 21 '05 #4
You are exactly correct. Everyting works perfectly now. Thank you very
much.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #5

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

Similar topics

8
3838
by: Bo Peng | last post by:
Dear list, I am writing a Python extension module that needs a way to expose pieces of a big C array to python. Currently, I am using NumPy like the following: PyObject* res =...
8
3943
by: Alex Vinokur | last post by:
Various forms of argument passing ================================= C/C++ Performance Tests ======================= Using C/C++ Program Perfometer...
58
10050
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...
2
3312
by: NM | last post by:
Hello all, I am supposed to do some mixed programming with c++ and fortran. I was succeeful in exchanging the 2D arrays from fortran to c++ and the other way, but was unable to that same with...
3
5535
by: SV | last post by:
Dear all, In my application I have a lot of hidden fields. I want to make them invisible for the users though for debugging reasons I want to make them visible. So I want to add these objects to...
0
1536
by: Richard Buckshaw | last post by:
Mimick the older C/ pascal dll parameter passing convention? - VB Class Mod? Hello, I have been attempting to write a VB class that would expose its stuff to an older (ok, legacy application)...
3
1751
by: Steve | last post by:
Hello, I created a public Structure in a Standard Module and also an array of Structures. Then I load data into the array of structures in a public sub that I call on the Form load event. ...
11
8095
by: John Pass | last post by:
Hi, In the attached example, I do understand that the references are not changed if an array is passed by Val. What I do not understand is the result of line 99 (If one can find this by line...
2
2264
by: goetzie | last post by:
I am using Python 2.4.1 and Numeric 23.8 and running on Windows XP. I am passing a Numeric array of strings (objects) to a C Extension module using the following python code: import Numeric...
0
7265
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7171
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...
1
7111
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...
0
5692
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,...
0
3240
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...
0
3228
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1605
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 ...
1
807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
461
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...

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.