+ Reply to Thread
Results 1 to 3 of 3

Simple Problem - Type Mismatch

  1. #1
    Registered User
    Join Date
    10-22-2007
    Posts
    37

    Probably Basic, But 'Type Mismatch'

    I'm new to vba functions, but I have read the documentation and I am still getting a "Type Mismatch," and I can't figure out why. I am taking the value entered into a combobox, assigning it to a string value (strCityName) and trying to determine if it has a space (a space character) within it.

    When I run this it tells me the list where I call InStr has a "Type Mismatch." InStr is supposed to return a 0 as a "Variant Long" value if there is no match and the starting position of the match if one is found. I've declared hasSpace as a Variant (and also As Long - but with the same error showing).

    InStr is supposed to take a String value, and I've defined strCityName as a string. Why am I getting a type mismatch?!


    Please Login or Register  to view this content.
    Last edited by rokuk; 11-16-2007 at 10:25 PM. Reason: more accurate

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    20,784
    Please Login or Register  to view this content.
    When you specify the CompareMode, which is 1 in your code, vbTextCompare,
    the first arg can not be ommitted.

    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    10-22-2007
    Posts
    37

    Thumbs up rawr

    AHHH - I can't believe I missed that!!

    Thank you so much for pointing that out to me. I was starting to think I was declaring variable types wrong or something...!!

    Thanks again!

+ 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