CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Strings

  1. #1

    Strings

    How do you search a string for the vbCrLf
    character and then separate the string into
    two strings without the vbCrLf character?


  2. #2
    Join Date
    Jun 2001
    Location
    Israel
    Posts
    228

    Re: Strings

    try this code:

    Dim tmp as string
    Dim s1 as string, s2 as string

    tmp = "First string" & vbCrLf & "Second string"
    s1 = mid$(tmp, 1, InStr(1, tmp, vbCrLf) - 1)
    s2 = mid$(tmp, InStr(1, tmp, vbCrLf) + 2,
    len(tmp)) 'vbCrLf is 2 chars, that's why + 2




    ----------
    The @host is everywhere!
    ----------

  3. #3
    Join Date
    Jan 2000
    Location
    Saskatchewan, Canada
    Posts
    595

    Re: Strings

    Try using the split function.

    Modify to suit your needs


    Dim tmp As String
    Dim s1() As String
    tmp = "First string" & vbCrLf & "Second string"
    s1 = Split(tmp, vbCrLf)
    Text1 = s1(0)
    Text2 = s1(1)



    David Paulson

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured