HELP "ByRef Argument Type Mismatch"

R

RocketMan

I get the compile error: ByRef Argument Type Mismatch
at the line Call Upate(itercount, a(i))

and it doesn't make sense to me. I am passing only one element of an
array and the types seems fine to me.

HELP

Here is the example:

Private type Iteration
Name as string
count as integer
end type

private type j
domain as string
it() as Iteration
end type

public function start()
dim i, itercount as integer
dim a(500) as j
itercount = Worksheet("iters").Range("c1")
for i = 0 to 499
redim a(i).it(itercount ) as Iteration
Call Update(itercount, a(i))
next

end function

' NOTE this function is in a separate ( .xla sheet) Module

Public Function Update(byval icount as long, byref DomIters as j)
' stuff done in here
end function
 
B

Bob Phillips

Define itercount as Long not Integer.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
R

RocketMan

OPPS, I misstyped.
Public Function Update(byval icount as long, byref DomIters as j)

is really
Public Function Update(byval icount as integer, byref DomIters as j)



Also, the compiler is highlighting the array element in the call
function.
 
C

Chip Pearson

Public Function Update(byval icount as integer, byref DomIters as j)

Unless 'j' is defined somewhere as a data type, you'll get an error.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting LLC
www.cpearson.com
(email on the web site)
 
R

RocketMan

it IS defined as a type at the top of the file.
Unless 'j' is defined somewhere as a data type, you'll get an error.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting LLC
www.cpearson.com
(email on the web site)
 
N

NickHK

I get a compile error on such a set up, as you cannot use user defined types
as arguments or return values in public routine.

Your type is private, so the Update routine cannot see it.
Maybe move to using a Class instead.

NickHK
 
R

RocketMan

OK, I accept that it isn' t possible. I 'broke up' the type into its
components to pass it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top