Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default ByRef Argument Type Mismatch

Excel 2003 SP3, Windows XP 5.1 SP3

The following call is generating the subject error, highlighting intRow.
Can anyone explain it to me?

....Calling procedure
strTag = Trim(ActiveControl.Tag)
intRow = Int(strTag)
ActiveSheet.Shapes("R" & strTag) = _
Round(GetMeansResult(intRow, Val(ActiveSheet.Shapes("txt" &
strTag)), 0))

....GetMeansResult function

Function GetMeansResult(Index As Integer, X As Single)

Thank you.

Sprinks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default ByRef Argument Type Mismatch

The caller is supplying an integer and the function expects a Single (float).
--
Gary''s Student - gsnu200798
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default ByRef Argument Type Mismatch

Sprinks wrote:
Function GetMeansResult(Index As Integer, X As Single)


Change that to

Function GetMeansResult(ByVal Index As Integer, ByVal X As Single)

and you're fine.

It's an annoying and most idiotic behaviour of VB to automatically
assume (and demand) all parameters to a function or sub to be passed by
reference, unless defined as ByVal.

HTH,

Lars
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default ByRef Argument Type Mismatch

strTag is a string. The Int function expects a number and it will return the
integer potion of that number. As a guess you are looking for the CInt
function which takes a string argument and coerces it to an integer. CLng
might be more approproate as it returns a long which is generally speaking
more efficient and less prone to failure...
--
HTH...

Jim Thomlinson


"Sprinks" wrote:

Excel 2003 SP3, Windows XP 5.1 SP3

The following call is generating the subject error, highlighting intRow.
Can anyone explain it to me?

...Calling procedure
strTag = Trim(ActiveControl.Tag)
intRow = Int(strTag)
ActiveSheet.Shapes("R" & strTag) = _
Round(GetMeansResult(intRow, Val(ActiveSheet.Shapes("txt" &
strTag)), 0))

...GetMeansResult function

Function GetMeansResult(Index As Integer, X As Single)

Thank you.

Sprinks

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default ByRef Argument Type Mismatch

Thanks, Jim.

"Jim Thomlinson" wrote:

strTag is a string. The Int function expects a number and it will return the
integer potion of that number. As a guess you are looking for the CInt
function which takes a string argument and coerces it to an integer. CLng
might be more approproate as it returns a long which is generally speaking
more efficient and less prone to failure...
--
HTH...

Jim Thomlinson


"Sprinks" wrote:

Excel 2003 SP3, Windows XP 5.1 SP3

The following call is generating the subject error, highlighting intRow.
Can anyone explain it to me?

...Calling procedure
strTag = Trim(ActiveControl.Tag)
intRow = Int(strTag)
ActiveSheet.Shapes("R" & strTag) = _
Round(GetMeansResult(intRow, Val(ActiveSheet.Shapes("txt" &
strTag)), 0))

...GetMeansResult function

Function GetMeansResult(Index As Integer, X As Single)

Thank you.

Sprinks



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default ByRef Argument Type Mismatch

Thanks, Lars.

"Lars Uffmann" wrote:

Sprinks wrote:
Function GetMeansResult(Index As Integer, X As Single)


Change that to

Function GetMeansResult(ByVal Index As Integer, ByVal X As Single)

and you're fine.

It's an annoying and most idiotic behaviour of VB to automatically
assume (and demand) all parameters to a function or sub to be passed by
reference, unless defined as ByVal.

HTH,

Lars

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 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
HELP "ByRef Argument Type Mismatch" RocketMan[_2_] Excel Programming 6 June 7th 07 07:00 PM
"ByRef argument type mismatch" Error Baapi[_4_] Excel Programming 2 September 17th 05 12:47 AM
ByRef argument type mismatch error? sermest Excel Programming 4 June 17th 05 06:50 PM


All times are GMT +1. The time now is 10:22 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"