Results 1 to 6 of 6

Thread: need help!

  1. #1

    Thread Starter
    Addicted Member cxj98's Avatar
    Join Date
    Feb 2007
    Posts
    170

    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.

  2. #2
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    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).

  3. #3

    Thread Starter
    Addicted Member cxj98's Avatar
    Join Date
    Feb 2007
    Posts
    170

    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.

  4. #4
    Hyperactive Member Chathura's Avatar
    Join Date
    Nov 2005
    Location
    Sri Lanka
    Posts
    345

    Re: need help!

    have more simple code.
    I can't beleive that "leinad31" code is complex. You can use
    Code:
    Instr
    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

  5. #5

    Thread Starter
    Addicted Member cxj98's Avatar
    Join Date
    Feb 2007
    Posts
    170

    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!

  6. #6
    Hyperactive Member Chathura's Avatar
    Join Date
    Nov 2005
    Location
    Sri Lanka
    Posts
    345

    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
  •  



Click Here to Expand Forum to Full Width