![]() |
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 |
ByRef Argument Type Mismatch
The caller is supplying an integer and the function expects a Single (float).
-- Gary''s Student - gsnu200798 |
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 |
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 |
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 |
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 |
All times are GMT +1. The time now is 07:20 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com