Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select Case - checking for "

Status
Not open for further replies.

Cleggy

MIS
Nov 14, 2001
9
GB
Hi,

I have some code that creates a file with a filename based on data in a particular field. I'm checking the data to strip out characters that might cause problems with the path/filename - :;\/ etc but have hit a problem checking for "

When I add """ to the end of the case statement Access changes it to """". How do I check for just "?

Here's the code:

Code:
For x = 1 To Len(filename)
        Select Case Mid(filename, x, 1)
        Case "\", "/", "?", "*", ":", ";", " "
            Mid(filename, x, 1) = "_"
        End Select
        Next x

Cheers.
 
instead of """ try chr$(34)


IE

case is chr$(34)
 
That's normal caracter " is replaced by "" withing a string, to avoid confusion with first and last "

So "" in a string is """", and this works:

Dim ArraySearch As Variant
Dim Search As Variant

ArraySearch = Array("\", "/", "?", "*", ":", ";", " ", """")

For Each Search In ArraySearch
filename = Replace(filename, Search, "_")
Next Search
 
Change the Select Case line to:
Case "\", "/", "?", "*", ":", ";", " ", Chr(34)

Mark Bolton
 
Thanks everyone, I've got it working.

TorF - you're right - it does appear to be normal, when I ran the code with """" it did work and strip out the "s - I guess I wasn't trusting enough of Access,when I saw it change it I just presumed it wouldn't work but didn't actually check it, d'oh :)

Thanks for all the suggestions everyone.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top