Solved

How do I remove hidden characters from a string

Posted on 2006-07-18
4
524 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now