|
-
Mar 8th, 2007, 07:41 PM
#1
Thread Starter
Addicted Member
need help!
Hi there!
follow is a *.txt,
##########
good
aaaaa (First content)
hello,
##########
oh, my god!
bbbbb (second content)
oh, my godness!
##########
ccccc (Third content)
##########
fdffdfa
ddddd (Last content)
dffadfdf
sdfdf
dfdfa
##########
How can i use richtextbox or textbox to read this *.txt to split each content between this -> ##########, thank you!
And how to use command button to create move first, Move Previous, move next, move last Method, etc. it move as database, like mark ablove, first content, second content, third content, Last content.
thank you, guys!
Last edited by cxj98; Mar 8th, 2007 at 07:53 PM.
-
Mar 8th, 2007, 08:57 PM
#2
Re: need help!
Code:
Dim intFF As Integer
Dim strGroups() As String
Dim lngIdx As Long
intFF = FreeFile
Open "C:\yourfile.txt" For Input As #intFF
strGroups = Split(Input(LOF(intFF), #intFF) ,"##########")
Close #intFF
For lngIdx = 1 To UBound(strGroups) - 1 'first and last array elements are "" strings
MsgBox strGroups(lngIdx) 'or txtCurrentGroup.Text = strGroups(lngCurrentIndex)
Next
So for next/previous simply increment/decrement you module scope variable for current array index. Movefirst goes to index 1 (skip index zero since its just zero length string), and movelast goes to index = ubound(array) -1 (again ignore trailing array element).
-
Mar 8th, 2007, 09:15 PM
#3
Thread Starter
Addicted Member
Re: need help!
many thanks for your reply.
does anyone who have other method or have more simple code.
thank you!
Last edited by cxj98; Mar 8th, 2007 at 09:22 PM.
-
Mar 8th, 2007, 10:36 PM
#4
Hyperactive Member
Re: need help!
I can't beleive that "leinad31" code is complex. You can use Function to do this. But it seems to be complex a bit. Anyway you'll have to use an array or a collection object to complete your solution. Therefore I think "leinad31" suggession is a good, simple and straightforward solution.
If the post is heplful, Please Rate it
Chathura Wijekoon
-
Mar 8th, 2007, 10:46 PM
#5
Thread Starter
Addicted Member
Re: need help!
use instr i think it only can seeking is "##########" exist, but can't split content between "##########", or may can, but can't use move first, Move Previous, move next, move last Method to get split content.
how about your ideal!
-
Mar 8th, 2007, 11:29 PM
#6
Hyperactive Member
Re: need help!
Yes, if you use Instr, you'll have to use mid,left or right functions in a loop to seperate your stuff and add into an Array or into a collection. That's y I told you that leinad31 code is better and straight forward.
If the post is heplful, Please Rate it
Chathura Wijekoon
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
|