?
Solved

passing an array to a sub routine

Posted on 2003-02-19
6
Medium Priority
?
205 Views
Last Modified: 2010-04-07

I am having trouble passing an array to a sub routine and can't seem to find out what I am doing wrong

Private Sub Command1_Click()
dim i as integer
Dim x(1 To 4000), y(1 To 4000) As Double
for i  = 1 to 4000
x(i) = i
y(i) = i
next i
'assume Form1.mnudynamic.Checked = True

If Form1.mnudynamic.Checked = True Then Call ggg(x(), y(), ctr, doseline, totpts)

'the error message I get is type mismatch: array or user-defined type expected
'it works when I take out the x(),y() and leave just the variables ctr doseline and totpts.  The problem is passing the whole array to the sub routine

thanks, Eric
0
Comment
Question by:wolfganngea
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 5

Accepted Solution

by:
bob_online earned 400 total points
ID: 7983902
Call ggg(x, y, ctr, doseline, totpts)

without the parens


An by the way, this

Dim x(1 To 4000), y(1 To 4000) As Double

is dimming x(a to 4000) as variant.  You need to specify the double for both

0
 
LVL 2

Expert Comment

by:Jacamar
ID: 7983982
Private sub Command1_Click()

dim X(1 to 4000) as double
dim Y(1 to 4000) as double

Call FILLARRAY (X(), Y())

end sub


Private sub FILLARRAY (X() as single, Y() as single

dim i as integer

for i  = 1 to 4000
x(i) = i
y(i) = i
next i

End Sub


Hopefully this helps

Jacamar
0
 

Expert Comment

by:maverick_niks
ID: 7984147
Call ggg(x() as Int, y() as Int, ctr, doseline, totpts)

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 2

Expert Comment

by:Jacamar
ID: 7989554
Call ggg(X() as double, Y() as double, ctr as 'datatype',doseline as 'datatype,totpts as 'datatype')


'datatype' is whatever type of data those variables are
0
 

Expert Comment

by:CleanupPing
ID: 8901417
wolfganngea:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8959716
Moderator, my recommended disposition is:

    Accept bob_online's comment(s) as an answer.

DanRollins -- EE database cleanup volunteer
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month10 days, 21 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question