Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How do I remove hidden characters from a string

Posted on 2006-07-18
4
Medium Priority
?
549 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

Industry Leaders: 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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

604 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