Returning from a Function

  • I keep getting a "type mismatch" error.
    I have tried dim to double on all quantities and add "As Double" to the end of

    "Function apparent(Byval v As Double, Byval b As Double, Byval T As Double) As Double"

    That gives the same "type mismatch" error.

  • Re: Returning from a Function

    How are you using this code that it gives you an error?

    I run the second code you posted by stepping through Sub first line by line with all your hard coded values and I get no error.

    You don't declare v, b or t in the code you posted, you just start using them and we don't know what Xec etc are or if you have declared them as a particular data type somewhere else, so it's hard to say.

    I will tell you this, if I run your code as you have shown, since v,b and t are not declared as a particular data type, they are variants and with variants Excel waits to see what the values you assign are before it decides what to do with the value.

    Therefore after running v=23, b=10 and T=0.000567, v is assigned by Excel as variant/integer, b is assigned as variant/integer and t is assigned as variant/double.

    But since I don't know how you are using this and what's going on with these other undefined variables and what you are doing with the return values I can't say what the problem is.

    Bruce :cool:

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!