Results 1 to 7 of 7

Thread: Help!!! Type mismatch

  1. #1

    Thread Starter
    Lively Member valchyshen's Avatar
    Join Date
    Mar 2001
    Location
    Kyiv, Ukraine
    Posts
    82

    Help!!! Type mismatch

    Here is my code:

    Dim DateD
    DateStr = "July 17, 2001"
    DateD = CDate(DateStr)
    ...

    Running it VB reports a run time error Type Mismatch. What is wrong?
    Best regards,

    Oleksandr Valchyshen
    A new one in VBA programming
    http://www.art-capital.com.ua/?lang=english

  2. #2
    When I use that code it works fine, is there some more, code, try hitting debug and it will find the faulty line

  3. #3

    Thread Starter
    Lively Member valchyshen's Avatar
    Join Date
    Mar 2001
    Location
    Kyiv, Ukraine
    Posts
    82
    I use bebug and the faulty line is
    DateD = CDate(DateStr)

    So, I cannot figure out what is wrong in code ...

    Originally posted by write2slappy
    When I use that code it works fine, is there some more, code, try hitting debug and it will find the faulty line
    Best regards,

    Oleksandr Valchyshen
    A new one in VBA programming
    http://www.art-capital.com.ua/?lang=english

  4. #4
    Well, either send you program to [email protected] or post all your code , and i will exmaine it further

  5. #5
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    I bet vb doesn't consider this a date,

    try MsgBox IsDate("July 17, 2001")
    it will return false ...
    -= a peet post =-

  6. #6
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    MSDN Say the following:

    CDate recognizes date formats according to the locale setting of your system. The correct order of day, month, and year may not be determined if it is provided in a format other than one of the recognized date settings. In addition, a long date format is not recognized if it also contains the day-of-the-week string.
    hope this can help you solve your problem
    -= a peet post =-

  7. #7

    Thread Starter
    Lively Member valchyshen's Avatar
    Join Date
    Mar 2001
    Location
    Kyiv, Ukraine
    Posts
    82
    Thank you all for helping me.
    VB really doesnot recognise "July 17, 2001" as a date, the following code returns false:

    DateStr="July 17, 2001"
    Msgbox IsDate(DateStr)

    My computer system is set to Russian version of date presentation. In my code I try to convert a date string with Ukrainian date "name-of-month-in-ukrainian dd, yyyy" to american date type "mmm dd, yyyyy", in result of all convertions I'd like to have a date value like that "17/07/01".
    Best regards,

    Oleksandr Valchyshen
    A new one in VBA programming
    http://www.art-capital.com.ua/?lang=english

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