Joining a string which is split by Carriage return Line Feed
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Joining a string which is split by Carriage return Line Feed

  1. #1
    Join Date
    May 2002
    Location
    Somewhere in Asia
    Posts
    96

    Question Joining a string which is split by Carriage return Line Feed

    Hello,

    I'm stuck in a situation now..I hope someone out there can help get me out of it...here's the situation:

    I now have a string as follows:

    abcstring =

    ABCDEFG
    HIJKLMNO
    PQRSTUV
    WXYZ


    how am I able to join all the strings to form a string

    ABCDEFGHIJKLMNOPQRSTUVWXYZ

    i.e. delete off the carriage return line feed


    Thanks in advance!

    Joe

  2. #2
    Join Date
    Apr 2002
    Location
    Melbourne, Victoria, Australia
    Posts
    1,792
    Make sure you have a reference to the Vb Scripting dll. (Microsoft Scripting Runtime - sccrun.dll)

    Then, use

    abcstring = replace(abcstring,chr(10),"")
    abcstring = replace(abcstring,chr(13),"")
    msgbox abcstring

  3. #3
    Join Date
    May 2002
    Location
    Somewhere in Asia
    Posts
    96
    Err..so sorry, mate,

    but how do I reference to the DLL?


    I've thought of another "primitive" method,

    what I did was, I split the string based of vbcrlf,

    i.e. Lines = Split(abcstring, vbCrLf)

    then I used a for loop to join them...

    the arrays of strings (Lines) up.

    Joseph

  4. #4
    Join Date
    Apr 2002
    Location
    Melbourne, Victoria, Australia
    Posts
    1,792
    Project->References

    Then select the dll I posted earlier
    NOTE - If you're using SourceSafe, you must check out your project file first.

  5. #5
    Join Date
    Sep 2001
    Location
    IL, USA
    Posts
    1,090
    Code:
    Private Sub Command1_Click()
       Dim Lines As Variant
       Lines = Split(abcstring, vbCrLf)
       MsgBox Join(Lines, "")
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center