+ Reply to Thread
Results 1 to 3 of 3

type mismatch

  1. #1
    Donnie Fuqua
    Guest

    type mismatch

    Can someone tell me, off the top of their head, why line 4 throws a type
    mismatch error?
    Note that the line numbers did not appear in the actual program code. Any
    help is much
    appreciated.

    1 Dim sngValue As Single
    2 For lngPattern = 1 To lngPatterns
    3 For lngInput = 1 To lngInputs
    4 sngValue = CSng(rngInputs.Offset(CVar(lngPattern - 1),
    CVar(lngInput - 1)).Value)
    5 FNet.SetInput lngPattern - 1, lngInput - 1, sngValue
    6 Next lngInput
    7 For lngOutput = 1 To lngOutputs
    8 sngValue = CSng(rngOutputs.Offset(CVar(lngPattern - 1),
    CVar(lngOutput - 1)).Value)
    9 FNet.SetOutput lngPattern - 1, lngOutput - 1, sngValue
    10 Next lngOutput
    11 Next lngPattern

    Donnie Fuqua



  2. #2
    Jim Cone
    Guest

    Re: type mismatch

    Donnie,
    Well from off the top of my head, I would say that the cell you
    are picking the .Value from cannot be converted to a Single.
    Find out what is in the cell and/or change CSng to Val as a test.
    Jim Cone
    San Francisco, USA


    "Donnie Fuqua" <[email protected]> wrote in message
    news:[email protected]...
    Can someone tell me, off the top of their head, why line 4 throws a type
    mismatch error?
    Note that the line numbers did not appear in the actual program code. Any
    help is much
    appreciated.

    1 Dim sngValue As Single
    2 For lngPattern = 1 To lngPatterns
    3 For lngInput = 1 To lngInputs
    4 sngValue = CSng(rngInputs.Offset(CVar(lngPattern - 1),
    CVar(lngInput - 1)).Value)
    5 FNet.SetInput lngPattern - 1, lngInput - 1, sngValue
    6 Next lngInput
    7 For lngOutput = 1 To lngOutputs
    8 sngValue = CSng(rngOutputs.Offset(CVar(lngPattern - 1),
    CVar(lngOutput - 1)).Value)
    9 FNet.SetOutput lngPattern - 1, lngOutput - 1, sngValue
    10 Next lngOutput
    11 Next lngPattern

    Donnie Fuqua



  3. #3
    Edwin Tam
    Guest

    RE: type mismatch

    First of all, I suggest to modify the line:
    sngValue = CSng(rngInputs.Offset(CVar(lngPattern - 1), _
    CVar(lngInput - 1)).Value)

    to:
    sngValue = rngInputs.Offset(lngPattern - 1, lngInput - 1).Value

    Those CSng and CVar might not be useless at all in your case.

    Concerning the Type Mismatch error, you need to verify the values of
    "lngPattern" and "lngInput" at the time of the error. (Use the Debug Window.)

    The problem should be due to, the value of the cell the statement was
    referring to didn't contain a numerical value. (For example, a string.)

    Regards,
    Edwin Tam
    [email protected]
    http://www.vonixx.com



    "Donnie Fuqua" wrote:

    > Can someone tell me, off the top of their head, why line 4 throws a type
    > mismatch error?
    > Note that the line numbers did not appear in the actual program code. Any
    > help is much
    > appreciated.
    >
    > 1 Dim sngValue As Single
    > 2 For lngPattern = 1 To lngPatterns
    > 3 For lngInput = 1 To lngInputs
    > 4 sngValue = CSng(rngInputs.Offset(CVar(lngPattern - 1),
    > CVar(lngInput - 1)).Value)
    > 5 FNet.SetInput lngPattern - 1, lngInput - 1, sngValue
    > 6 Next lngInput
    > 7 For lngOutput = 1 To lngOutputs
    > 8 sngValue = CSng(rngOutputs.Offset(CVar(lngPattern - 1),
    > CVar(lngOutput - 1)).Value)
    > 9 FNet.SetOutput lngPattern - 1, lngOutput - 1, sngValue
    > 10 Next lngOutput
    > 11 Next lngPattern
    >
    > Donnie Fuqua
    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1