473,785 Members | 2,440 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_Sele ctedIndexChange d(ByVal sender As
System.Object, ByVal e As System.EventArg s) Handles
cboEmpName.Sele ctedIndexChange d

Dim ename As String

cerow = 2

ename = cboEmpName.Sele ctedItem

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.activeshe et.Cells(1,1).c urrentregion.ro ws.count

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

'do more stuff

End Sub

the arrays in Private Sub cboEmpName_Sele ctedIndexChange d 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 1680
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_Sele ctedIndexChange d(ByVal sender As
System.Object, ByVal e As System.EventArg s) Handles
cboEmpName.Sele ctedIndexChange d

Dim ename As String

cerow = 2

ename = cboEmpName.Sele ctedItem

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.activeshe et.Cells(1,1).c urrentregion.ro ws.count

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

'do more stuff

End Sub

the arrays in Private Sub cboEmpName_Sele ctedIndexChange d 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.co m> wrote in message
news:%2******** ********@TK2MSF TNGP15.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
3867
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 = PyArray_FromDimsAndData(1, int*dim, PyArray_DOUBLE, char*buf); Users will get a Numeric Array object and can change its values (and actually change the underlying C array).
8
3969
by: Alex Vinokur | last post by:
Various forms of argument passing ================================= C/C++ Performance Tests ======================= Using C/C++ Program Perfometer http://sourceforge.net/projects/cpp-perfometer http://alexvn.freeservers.com/s1/perfometer.html
58
10181
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);
2
3325
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 the 3D arrays, the values passed are not all the same. I am also pasting the fortran and c++ codes so that you could have a look at them. ////C++ Code
3
5562
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 an array-variable and pass this variable to a subroutine in which I make all stored objects in the array-variable invisible. Can somebody explain me how to declare the correct variables, how to pass these to a sub routine and how to make these...
0
1546
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) program which can load and call exported functions from the old style dlls. With little documentation to go on, my legacy app defines
3
1764
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. Next I have a class, and I want to pass a structure member from my array of Structures to the class constructor. In the form I instantiate a class object. Module1
11
8131
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 number) which is the last line of the following sub routine: ' procedure modifies elements of array and assigns ' new reference (note ByVal) Sub FirstDouble(ByVal array As Integer()) Dim i As Integer
2
2278
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 import TestDLL # my C Extension Module a = Numeric.array(, 'O' ) print 'a =', a print 'type a =', type(a)
0
9647
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9489
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
10357
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10162
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
10101
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
8988
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...
0
5528
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4063
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
2
3665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.