|
-
Apr 12th, 2006, 12:05 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Delimit based on Space
Can anyone help me delimit text files by " "? I have searched the forums but have nto yet found anyone delimiting to pull out each word. I want to pull out each separate word of a text file. Any help would be greatly appreciated. Thank you.
VB Code:
Private Sub Command1_Click()
Dim str As String
Dim lines() As String
Open "C:\file.txt" For Input As #1
str = Input(LOF(1), #1)
lines = Split(str, vbNewLine)
For N = LBound(lines) To UBound(lines)
word = Split(lines, " ")
Next N
Close #1
For N = LBound(newText) To UBound(newText)
str = str & newText(N)
Next N
Open "C:\newFile.txt" For Output As #2
Print #2, str
Close #2
End Sub
Nenio foriras ĝis ĝi havas instru ni kiu ni devas scii.
-
Apr 12th, 2006, 12:09 PM
#2
Re: Delimit based on Space
VB Code:
Private Sub Command1_Click()
Dim word() As String
Open "C:\file.txt" For Input As #1
words = Split(Input(LOF(1), #1), " ")
Close #1
For N = 0 To UBound(words)
str = str & words(N)
Next N
Open "C:\newFile.txt" For Output As #2
Print #2, str
Close #2
End Sub
(Not sure what you want your end result to be.. this code splits by space then rebuilds the string with no spaces??)
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Apr 12th, 2006, 12:10 PM
#3
Re: Delimit based on Space
this will do the same thing... removes spaces (and vbcrlf (vbNewLine))
VB Code:
Private Sub Command1_Click()
Dim str As String
Open "C:\file.txt" For Input As #1
str = Input(LOF(1), #1)
Close #1
str = Replace(str, " ", "")
str = Replace(str, vbCrLf, "")
Open "C:\newFile.txt" For Output As #2
Print #2, str
Close #2
End Sub
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Apr 12th, 2006, 12:25 PM
#4
Thread Starter
Addicted Member
Re: Delimit based on Space
No I don't want to remove the space just want to pull out each word. For example, in the preceeding sentence I don not want: "NoIdon'twanttoremovethespacejustwanttopullouteachword"
However, I do want:
No
I
don't
want
to
remove
the
space
just
want
to
pull
out
each
word
Thanks though for the code
Nenio foriras ĝis ĝi havas instru ni kiu ni devas scii.
-
Apr 12th, 2006, 12:39 PM
#5
Re: Delimit based on Space
give this a shot then
VB Code:
Private Sub Command1_Click()
Dim word() As String
Open "C:\file.txt" For Input As #1
words = Split(Replace(Input(LOF(1), #1), vbCrLf, ""), " ")
Close #1
For N = 0 To UBound(words)
str = str & words(N) & vbCrLf
Next N
Open "C:\newFile.txt" For Output As #2
Print #2, str
Close #2
End Sub
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Apr 12th, 2006, 12:45 PM
#6
Thread Starter
Addicted Member
Re: Delimit based on Space
Nenio foriras ĝis ĝi havas instru ni kiu ni devas scii.
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
|