VBA byref argument type mismatch when calling a function from a function being called -


hope can help. simplification of set of code i'm working with. i'm calling function, , function calls function. variables passed calling sub first called function, should passed 2nd called function return value. however, i'm getting "byref argument type mismatch" error on below "parameter" in first function. suggestions? thanks!

' sub call function 1 sub testfunctionselect()     dim x double     ' x should = value of function msharemmtdaily called mfunctionselect     x = mfunctionselect("msharemmtdaily", "sol", "2008/02/28", 12) end sub  ' function 1 call function 2 , return value sub function mfunctionselect(functionname string, compcode string, currentmonth date, parameter double) double     select case functionname         ' case = "mvalue"             ' mfunctionselect = mvalue(compcode, currentmonth, parameter)         case = "msharemmtdaily"             ' function called             ' "byref argument type mismatch" error on below "parameter"             mfunctionselect = msharemmtdaily(compcode, currentmonth, parameter)     end select end function  function msharemmtdaily(code string, sharedate date, lookback integer) double     ' stuff end function 

your parameter variable declared double , passing function expects integer. should convert it, in:

mfunctionselect = msharemmtdaily(compcode, currentmonth, cint(parameter)) 

btw., @dee pointed out - doing implicit conversion of string date. makes code less safe , dependent on language settings of host on code runs. should convert date explicitly or, better yet, work dates beginning instead of strings.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -