Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default ByRef argument type mismatch

I have two code modules, one named "Primary" and the other is "Utils".

'The "Utils" module has the following subroutine:
'-----------------------------------------------
Public Sub Foo (a as Integer, b as Integer)
MsgBox "Nothing here."
End Sub

' The "Primary module has the following subroutine:
'-------------------------------------------------
Public Sub Goo()
Dim x, y as Integer
x = 2
y = 3
Utils.foo x, y ' ByRef argument error here
End Sub


When you run the Goo() subroutine, you get the
"ByRef argument type mismatch". What's wrong here?

-Robert
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default ByRef argument type mismatch

RG III wrote in :

I have two code modules, one named "Primary" and the other is "Utils".

'The "Utils" module has the following subroutine:
'-----------------------------------------------
Public Sub Foo (a as Integer, b as Integer)
MsgBox "Nothing here."
End Sub

' The "Primary module has the following subroutine:
'-------------------------------------------------
Public Sub Goo()
Dim x, y as Integer
x = 2
y = 3
Utils.foo x, y ' ByRef argument error here
End Sub


When you run the Goo() subroutine, you get the
"ByRef argument type mismatch". What's wrong here?


'x' isn't (necessarily) an Integer, it's a Variant (unless there's a Deftype
statement somewhere). You have to specify each variable's type to change it
from the default:

Dim x as Integer, y as Integer

--
He felt emptied, a shell without emotions.
Everything he touched brought death and grief.
And it was like a disease that could spread across the universe.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ByRef argument type mismatch (repost) Robert Crandal[_3_] Excel Programming 7 April 2nd 15 03:51 PM
ByRef Argument Type Mismatch Sprinks Excel Programming 5 August 8th 08 04:11 PM
ByRef Argument Type mismatch Tone[_4_] Excel Programming 4 July 3rd 08 02:35 PM
ByRef argument type mismatch when passing dictionary object signon77 Excel Programming 7 January 8th 08 10:03 PM
ByRef argument type mismatch error? sermest Excel Programming 4 June 17th 05 06:50 PM


All times are GMT +1. The time now is 08:59 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"