Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
ByRef Argument Type Mismatch
The caller is supplying an integer and the function expects a Single (float).
-- Gary''s Student - gsnu200798 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
ByRef Argument Type mismatch | Excel Programming | |||
ByRef argument type mismatch when passing dictionary object | Excel Programming | |||
HELP "ByRef Argument Type Mismatch" | Excel Programming | |||
"ByRef argument type mismatch" Error | Excel Programming | |||
ByRef argument type mismatch error? | Excel Programming |