|
-
Dec 7th, 2002, 06:20 PM
#1
Thread Starter
Lively Member
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
-
Dec 7th, 2002, 06:41 PM
#2
VB Code:
'place in a form (make Public if in to module)
Private Function AnalyseLine(ByVal Text As String) As String
Dim MyName As String, MyValue As String
If InStr(Text, ". ") Then MyName = Trim$(Left$(Text, InStr(Text, ". ")))
If InStr(Text, ": ") Then MyValue = Trim$(Mid$(Text, InStr(Text, ": ") + 2))
AnalyseLine = MyName & "|" & MyValue
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.
-
Dec 7th, 2002, 07:13 PM
#3
Need-a-life Member
This would let you parse lines like I.P. Routing Enabled. . . . . . . . : No
VB Code:
Private Function AnalyseLine(ByVal Text As String) As String
Dim MyName As String, MyValue As String
If InStr(Text, ": ") Then MyValue = Trim$(Mid$(Text, InStr(Text, ": ") + 2))
MyName = Trim$(Left$(Text, InStr(Text, ": " & MyValue) - 1))
Do Until Right(MyName, 1) <> "."
MyName = Trim$(Left$(MyName, Len(MyName) - 1))
Loop
AnalyseLine = MyName & "|" & MyValue
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.
-
Dec 7th, 2002, 09:19 PM
#4
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|