Results 1 to 12 of 12

Thread: Retrieve a Line from a string!

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    879

    Angry

    Hey sup? I have a string with over 90 lines and I want to retrieve a whole line from this string! Can anyone help me do that? Don't forget, I have had a few codes before that work properly but if there's a line and then a double space and then there's another line, the code stops to work properly!
    Visual Basic 6.0
    Visual C++ 5
    Delphi 5


  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    879

    Talking Clairifing things

    Ok here's what my string looks like but it's a bit bigger!
    Code:
    <HTML>
    <HEAD>
    <TITLE></TITLE>
    </HEAD>
    
    <BODY>
    
    <IFRAME SRC="WHATEVER">
    </BODY>
    </HTML>
    Lets say I want to retrieve the Line with the IFrame on it just by giving it the line number 8! So when I tell it to get line 8 I want it to get me the line with the <IFRAME SRC="WHATEVER"> ! Can anyone help me out! Thanx
    Visual Basic 6.0
    Visual C++ 5
    Delphi 5


  3. #3
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    Private Sub Command1_Click()
    
    Open "C:\my documents\try.txt" For Input As #1
     Do While Not EOF(1)
       Line Input #1, mystring
         i = i + 1
       If i = 8 Then
          MsgBox mystring
       End If
          Loop
             Close #1
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    879
    That won't work because the HTML is in a string! Saving the HTML to a file will slow down the program dramatically!
    Visual Basic 6.0
    Visual C++ 5
    Delphi 5


  5. #5
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Thumbs up VB Regular Expression

    Actually you can use the VB Regular Expression to perform a very powerful sear in your plan text file. (Which I learn this from the Advisor.com) may be you can visit the web site or just download the VBScript.DLL from the microsoft web site.

    I did create a sample program as the Advisor.com show, If you interest juz email me & I'll email it to you.

    It really a create tools to manipulate a plan text file like HTML, XML, WML, ASP or any others.


  6. #6
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    'here I put it in a string and split it and
    'you always want 1 less than you want as arrays are
    'zero based
    
    Private Sub Command1_Click()
    Open "C:\my documents\try.txt" For Input As #1
     mystring = StrConv(InputB(LOF(1), 1), vbUnicode)
     Close #1
     
     Dim myVar
     myVar = Split(mystring, vbCrLf)
     
      MsgBox myVar(7)
    End Sub
    You don't have to use the file like I did I just did it cause I was too lazy to create a string when I already had the content in a file.


    [Edited by HeSaidJoe on 11-16-2000 at 08:14 AM]
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  7. #7
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    HeSaidJoe, also close the file.
    Code:
    Close #1
    Oetje
    [email protected]
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

  8. #8
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
     Say what?????
    
    Private Sub Command1_Click()
    Open "C:\my documents\try.txt" For Input As #1
       mystring = StrConv(InputB(LOF(1), 1), vbUnicode)
     Close #1
     
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  9. #9
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    Sorry, I din't see it because of the tabs.
    Oetje
    [email protected]
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

  10. #10
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>


    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    879
    can any1 help me out! I need a better way!
    Visual Basic 6.0
    Visual C++ 5
    Delphi 5


  12. #12
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    As I said in the edit, you don't need to import the file, I just used it cause I didn't have a string of html at hand.
    The whole of my code was this.

    Dim myVar
    myVar = Split(mystring, vbCrLf)


    As for better, what exactly do you want?

    the code splits the string on vbCrlf and stores each
    indivual line in an array from which you can pull any
    line number you want. You only have to remember that the array is zero based so line 8 is line 7. And for that matter you can redim preserve myVar (1 to ubound(myVar)and then line 8 is line 8.

    ????


    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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