Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
Solved

# passing an array to a sub routine

Posted on 2003-02-19
Medium Priority
213 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
Question by:wolfganngea
6 Comments

LVL 5

Accepted Solution

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

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

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

0

LVL 2

Expert Comment

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

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

ID: 8959716
Moderator, my recommended disposition is:

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

DanRollins -- EE database cleanup volunteer
0

## Featured Post

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
###### Suggested Courses
Course of the Month13 days, 11 hours left to enroll

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

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