Solved

How do I remove hidden characters from a string

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

809 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