Results 1 to 4 of 4

Thread: parsing, splitting Nightmare

  1. #1

    Thread Starter
    Lively Member dedub's Avatar
    Join Date
    Dec 2002
    Location
    NC
    Posts
    98

    parsing, splitting Nightmare

    Ive read all I could possible read on this subject to no avail. Im sure the answer is easy I just CANT get it

    This is part of the .txt/.log file I'm trying to separate into its own RichTextBox.
    -------------------------------------
    Windows 2000 IP Configuration



    Host Name . . . . . . . . . . . . : parents
    Primary DNS Suffix . . . . . . . :
    Node Type . . . . . . . . . . . . : Broadcast

    IP Routing Enabled. . . . . . . . : No

    WINS Proxy Enabled. . . . . . . . : No

    DNS Suffix Search List. . . . . . : nc.rr.com
    ----------------------------------------
    All I want to do is pull the specific info like the word "parents" and put it into the mentioned box.

    Ive tried: selLenth, Seltart, Span,InStr,Split,InBetween and who knows what else.
    I've had luck with split but all I can do with that is pull out info that is between "like chacters" ie..commas and colons. I need to get inbetween some constant words that wont change in the file like "Host Name" and the word "Primary", remember the word "parents" will change from computer to computer.

    Any and all help is appreciated
    R.L.T.W. A+, NET+, CCNA

    Doin' my best

  2. #2
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    VB Code:
    1. 'place in a form (make Public if in to module)
    2. Private Function AnalyseLine(ByVal Text As String) As String
    3.     Dim MyName As String, MyValue As String
    4.     If InStr(Text, ". ") Then MyName = Trim$(Left$(Text, InStr(Text, ". ")))
    5.     If InStr(Text, ": ") Then MyValue = Trim$(Mid$(Text, InStr(Text, ": ") + 2))
    6.     AnalyseLine = MyName & "|" & MyValue
    7. End Function

    For the line Host Name . . . . . . . . . . . . : parents this should return Host Name|parents

    For each line you told it should return (as I didn't test the code...sorry about that):

    Code:
    |
    |
    |
    |
    Host Name|parents 
    Primary DNS Suffix|
    Node Type|Broadcast 
    |
    IP Routing Enabled|No
    |
    WINS Proxy Enabled|No
    |
    DNS Suffix Search List|nc.rr.com 
    |
    Use this function when you have done Line Input while reading the file. Hope this is of any help
    Last edited by Merri; Dec 7th, 2002 at 06:46 PM.

  3. #3
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    This would let you parse lines like I.P. Routing Enabled. . . . . . . . : No
    VB Code:
    1. Private Function AnalyseLine(ByVal Text As String) As String
    2.     Dim MyName As String, MyValue As String
    3.     If InStr(Text, ": ") Then MyValue = Trim$(Mid$(Text, InStr(Text, ": ") + 2))
    4.    
    5.     MyName = Trim$(Left$(Text, InStr(Text, ": " & MyValue) - 1))
    6.     Do Until Right(MyName, 1) <> "."
    7.         MyName = Trim$(Left$(MyName, Len(MyName) - 1))
    8.     Loop
    9.    
    10.     AnalyseLine = MyName & "|" & MyValue
    11. End Function
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  4. #4

    Thread Starter
    Lively Member dedub's Avatar
    Join Date
    Dec 2002
    Location
    NC
    Posts
    98
    Thanks to you Both, your code has helped me Immeasurably. Not only has my project started moving again I learned a little about parsing, thanks again!

    ds
    R.L.T.W. A+, NET+, CCNA

    Doin' my best

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