Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing CR or VbCrLf from text string!! 1

Status
Not open for further replies.

MAT2001

Technical User
Feb 22, 2001
20
CA
I am trying to create a formula in Crystal Reports 8.5 using Visual Basic.

Require the Text field to have all carriage returns removed, but have not been able to get the 'replace' command to work. Note that I browsed the data field while in Crystal and see the CR as little black boxes!

The end result I am looking for is to have text print and wrap at approx. 30 characters, and then if necessary add a CR at end to ensure that the data fills even number of lines. So if last line of data writes to an odd line the CR will be added to force a blank line at bottom, which then keeps record use to even lines.

I am fairly new at programming and would really appreciate any help! Have tried using Crystal formulas with no luck, as fairly limiting. TY :)
 
What are you trying to accomplish? Passing formatted text to a report? Or are yuo actually trying to build a formula dynamically? AIf you could post the code that is not working that would be helpful too.
This Line should replace the 'little black boxes' if they are the ones i'm thinking of.
Code:
TextStr = Replace(TextStr, "", "")
Ruairi

Could your manufacturing facility benefit from real time process monitoring? Would you like your employees to be able to see up to the minute goal and actual production?
For innovative, low cost solutions check out my website.
 
I am trying to pass the text to a report without the CR and have not been able to remove the CR, as views as the little black box. Next stupid question - how did you display that little black box?

TY for your help! On to the next phase!
 
This may not be the most efficient, but it removes any CRs or LFs.
Code:
    Dim sString As String
    Dim iPos As Long

    sString = "This is the" & vbCrLf & "test string." & _
              vbCr & "Here is" & vbLf & "some more."
    
    MsgBox sString
    
    'Replace all with a space
    
    'Remove CR
    iPos = InStr(1, sString, vbCr)
    Do While iPos > 0
        sString = Left(sString, iPos - 1) & _
                  Space(1) & _
                  Right(sString, Len(sString) - iPos)
        iPos = InStr(1, sString, vbCr)
    Loop
    'Remove LF
    iPos = InStr(1, sString, vbLf)
    Do While iPos > 0
        sString = Left(sString, iPos - 1) & _
                  Space(1) & _
                  Right(sString, Len(sString) - iPos)
        iPos = InStr(1, sString, vbLf)
    Loop

    MsgBox sString
DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
MAT2001,
I was having problems with that little black box when trying to import legacy data into a SQL Server database. I had to open the text file with the black box and cut and paste it into vb. It's not a stupid question, it took me a while to figure out how to remove it. Ruairi

Could your manufacturing facility benefit from real time process monitoring? Would you like your employees to be able to see up to the minute goal and actual production?
For innovative, low cost solutions check out my website.
 
Thank you for all the help. I never did manage to get anything that could read the characters such that I could cut and paste the little black box. Through some additional reseach came up with an idea that lead me to do the following replace command in Crystal Reports.
VDesc = Replace(ItemDesc, chr(13) & chr(10), " ")

Originally I had two replace lines in formula one for the chr(13) & another for chr(10), which did not work. For some reason searching for them together one after the other works!

Appreciate all the help! Total newbie and learning as I go.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top