+ Reply to Thread
Results 1 to 3 of 3

Type mismatch when calling sub procedure..

  1. #1
    Registered User
    Join Date
    05-30-2010
    Location
    hk
    MS-Off Ver
    Excel 2003
    Posts
    17

    Type mismatch when calling sub procedure..

    so basically i am working on one sub which calls another sub . I don't know why whenever the value of ray is "" (NULL). VB shows runtime error 13-Type mismatch, on this code
    "tot = tot + n"
    Hope someone can answer my stupid question. Thanksss a lot in advance.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Type mismatch when calling sub procedure..

    Hmmm, this is just a guess, but I'm thinking its because you never state a value for x. If you check ray(x), you are just running the check function on the member # x of the ray array. I've never personally used the split function, but based on the help it seems like you need to enter a string, not an array. Does that make sense?
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: Type mismatch when calling sub procedure..

    christheta;

    You Dim n as variant, which means that it becomes the type that is contained in "Content"
    Split("") returns nothing (probably a string) witch n accepts with no conversion.

    And when you want to add a string onto a double VB crashes.
    It's equivalent to saying tot = 0 + "". In the immediate window try ? 0 + "" and you'll get the same error.

    If you were to Dim n as Integer (or Double, or Long, etc), then VB would try to convert each element in Content into an integer before trying to add it to n.
    Foxguy

    Remember to mark your questions [Solved] and rate the answer(s)
    Forum Rules are Here

+ 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