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

Thread: Strings

  1. #1

    Strings

    What represents a new line in a String? I thought it would be line feed, but it isn't...
    So, what is it?


  2. #2
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Strings

    chr$(13) & chr$(10)
    or
    vbCrlf

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  3. #3

    Re: Strings

    When I try using the InStr function to look for those characters in a string it does not find them!


  4. #4
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: Strings

    here is a quick sample using VBcr, vblf and vbcrlf

    option Explicit

    private Sub Command1_Click()
    Dim str, X
    'str = "The quick Brown Fox" & vbCrLf & "Jumps over the lazy dog"
    ' either way will work
    str = "The quick Brown Fox" & vbCr & vbLf & "Jumps over the lazy dog"
    X = InStr(str, vbCrLf)
    MsgBox X
    End Sub




    John G

  5. #5
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Strings


    option Explicit

    private Sub Command1_Click()
    Dim strString as string
    strString = "blablabla" & Chr$(13) & Chr$(10) & "blablablabla"
    MsgBox fnctFindIt(strString) 'will be 10
    strString = "blablablablab" & vbCrLf & "blablablabla"
    MsgBox fnctFindIt(strString) 'will be 14
    End Sub
    private Function fnctFindIt(byval strParm as string) as string
    Dim intFoundPos as Integer
    intFoundPos = InStr(1, strParm, Chr$(13) & Chr$(10), vbBinaryCompare)
    If intFoundPos > 0 then
    fnctFindIt = "Line feed and carriage return found starting at " & intFoundPos & " position"
    else
    fnctFindIt = "Line feed and carriage return NOT found"
    End If
    End Function





    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

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