By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,368 Members | 1,294 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,368 IT Pros & Developers. It's quick & easy.

passing an array to a module

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.