Results 1 to 14 of 14

Thread: [RESOLVED] type mismatch

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2005
    Posts
    18

    Resolved [RESOLVED] type mismatch

    Im not sure if this is the correct place to post this query but i hope so.

    Why do i get a type mismatch Run-time error 13, for the following piece of code???

    VB Code:
    1. returns(a) = "=Average(loser["& a &" "& b &"]:loser ["& a &" "& b+10 &"])"

    If returns(a) and loser(a, b) are defined as Single then why is there a mismatch?

    Any help would be most appreciated.
    Last edited by Zahida.Laljee; Jul 26th, 2005 at 01:53 PM.

  2. #2
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: type mismatch

    You have a string on ther right side of the equation, but there is no quote to close it

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2005
    Posts
    18

    Re: type mismatch

    that was a typo in my question there is quotation to close it - but thanks

  4. #4
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: type mismatch

    Uhh, seems to me you're assigning a string to a single then

    I dont exactly understand what that line of code is trying to do though

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jul 2005
    Posts
    18

    Re: type mismatch

    Loser() contains values that need to be used to calculate the average returns.

    so although it is entering a string into the array component of returns(a) it is supposed to enter the average value of loser(a,b) and loser(a, b+1). Does that make any sense?

  6. #6
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: type mismatch

    not exactly to me , however, simply looking at

    "=Average()" leads me to believe it is a string..the average function is meant to be used with single values is it not?

  7. #7
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: type mismatch

    Are you using Excel? It required cell reference as A1, and loser(1,1) won't work.

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Jul 2005
    Posts
    18

    Re: type mismatch

    but the value is contained in loser array component(1,1)?!?!?

  9. #9
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: type mismatch

    im just gonna remove the strings..is this what you want?

    returns(a) = Average(loser[a,b]:loser [a,b+10])

    ?

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Jul 2005
    Posts
    18

    Re: type mismatch

    but that doesn't compile because a list seperator or ) needed?

    zee xxx

  11. #11
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: type mismatch

    This is Excel isn't it? You are using the : symbol to indicate a range?

  12. #12
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: type mismatch

    Or is this what you want?
    VB Code:
    1. Dim i As Long
    2. Dim sngAvg As Single
    3. For i = b To (b + 10)
    4.     sngAvg = sngAvg + Loser(a, i)
    5. Next i
    6. sngAvg = sngAvg / 11
    7. Returns(a) = sngAvg
    ?

  13. #13

    Thread Starter
    Junior Member
    Join Date
    Jul 2005
    Posts
    18

    Re: type mismatch

    thank you very much

  14. #14
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: type mismatch

    No worries, I take it the second one did it

    Please mark your thread resolved using the Thread Tools menu.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width