?
Solved

How do I remove hidden characters from a string

Posted on 2006-07-18
4
Medium Priority
?
544 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 85
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 1000 total points
ID: 17133494
thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

762 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