+ Reply to Thread
Results 1 to 8 of 8

Find invalid character in string

  1. #1
    Forum Contributor
    Join Date
    09-03-2008
    Location
    Somerset, England
    MS-Off Ver
    XP, 2003, 2007 - depends on location
    Posts
    185

    Find invalid character in string

    Hi all,

    I have a macro that asks the user to enter a file name and have written a small function to search the name given to the file to find any invalid characters, trouble is I must be doing something wrong as I doesn't work. Everytime I write something in the box I'm told it's invalid, regardless of weather it actually is or not.

    Function -

    Please Login or Register  to view this content.
    I call the function like this -

    Please Login or Register  to view this content.
    If anybody could let me know where I am going wrong I'd appriciate it.

    Thanks.
    Last edited by duckboy1981; 01-23-2009 at 05:56 AM. Reason: Forgot to write something

  2. #2
    Valued Forum Contributor Richard Schollar's Avatar
    Join Date
    05-23-2006
    Location
    Hampshire UK
    MS-Off Ver
    Excel 2002
    Posts
    1,264
    Hi

    Default value of a Boolean is False and you never actually set it to True - hence the Do condition is always True.

    Richard
    Richard Schollar
    Microsoft MVP - Excel

  3. #3
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    You have the <> 0 at the end, but you need to list it for each test. For example:

    Please Login or Register  to view this content.
    HTH

    Jason

    Edit: Richard's response, too.

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531
    I think you could argue that the <> 0 is not required given only the value 0 equates to FALSE ... any other value equates to TRUE by default

  5. #5
    Forum Contributor
    Join Date
    09-03-2008
    Location
    Somerset, England
    MS-Off Ver
    XP, 2003, 2007 - depends on location
    Posts
    185
    Thaks for replies all. I have amended the fucntion so every test has '<> 0' at the end and switched the result to 'True' if any of the tests return a result other than 0

    It's now allowing me to progress all the time if I write -

    Please Login or Register  to view this content.
    And not allowing me to progress at all if the code is -

    Please Login or Register  to view this content.
    I'm probably just being a fool, but if you could have a look again Id apriciate it.

    Thanks.

  6. #6
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Try chaning to the following:

    Please Login or Register  to view this content.
    HTH

    Jason

  7. #7
    Forum Contributor
    Join Date
    09-03-2008
    Location
    Somerset, England
    MS-Off Ver
    XP, 2003, 2007 - depends on location
    Posts
    185
    Sorted - Thanks muchly

  8. #8
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Glad it helped.

    Jason

+ 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