Solved

How do I remove hidden characters from a string

Posted on 2006-07-18
4
528 Views
Last Modified: 2009-07-29
I have created a file upload dialog that simply puts the path to the file in a text box, however when I try to save the string to the DB there is hidden characters at the end of the path  to be exact. The Access DB does not like the  character. How do I avoid getting these into my string, simpler yet How can I find the start of the .   If I can trim everything after the file name (c:\images\joe.jpg) that would be great but I can not seem to just trim after the .jpg . Help
0
Comment
Question by:agilebiz
  • 2
4 Comments
 
LVL 84
ID: 17133246
Those are probably CarriageReturn/LineFeed characters.

You didn't say what version of Access you were using, but in Access 2000+ you can use the Replace function:

Replace(YourString, vbCrLf, "")

They could be these as well:

vbCR
vbLF
vbTab

or a few others ... try each and see what returns the best result.

0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17133341
try this function to remove characters


Public Function StripHighBitChars(sMemoText As String) As String

    Dim sReturn As String
    Dim x
   
    sReturn = ""
    For x = 1 To Len(sMemoText)
   
        ' The space character is 32.  Tilde (~) is the last low-bit printable character at 126.
        ' Chr(127) is DEL (non-printable) on a lot of systems now, so I did not include it.
        If ((Asc(Mid(sMemoText, x, 1)) > 31) And (Asc(Mid(sMemoText, x, 1)) < 127)) Then _
            sReturn = sReturn & Mid(sMemoText, x, 1)
    Next
   
    StripHighBitChars = sReturn

End Function



Simply pass in your string
e.g.

    Dim sNewStr As String
   
    sNewStr = "c:\images\joe.jpg"
    MsgBox "Before : " & sNewStr
    sNewStr = StripHighBitChars(sNewStr)
    MsgBox "After : " & sNewStr

0
 

Author Comment

by:agilebiz
ID: 17133480
Thanks RockiRoads your function worked great!!!  Very Slick
0
 
LVL 65

Accepted Solution

by:
rockiroads earned 250 total points
ID: 17133494
thanks
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question