-
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!
-
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).
-
Re: need help!
many thanks for your reply.
does anyone who have other method or have more simple code.
thank you!
-
Re: need help!
Quote:
have more simple code.
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.
-
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!
-
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.