Results 1 to 5 of 5

Thread: help extract string from richtextbox to listbox urgent

  1. #1

    Thread Starter
    Banned
    Join Date
    Nov 2012
    Posts
    1,171

    help extract string from richtextbox to listbox urgent

    Code:
    mail:</td><td class="field"><input name="OWNER_EMAIL" value="" size="40" maxlength="255" class="text" type="text"></td></tr><tr><td class="label"><span class="req">*</span>Category:</td><td class="field"><select name="CATEGORY_ID"><option value="0" selected="selected" disabled="disabled">[Top]</option><option value="1">|___Arts &amp; Humanities</option><option value="2">|&nbsp;&nbsp;&nbsp;|___Art History</option><option value="3">|&nbsp;&nbsp;&nbsp;|___Art Weblogs</option><option value="4">|&nbsp;&nbsp;&nbsp;|___Artists</option><option value="5">|&nbsp;&nbsp;&nbsp;|___Awards</option><option value="6">|&nbsp;&nbsp;&nbsp;|___Booksellers</option><option value="7">|&nbsp;&nbsp;&nbsp;|___Censorship</option><option value="8">|&nbsp;&nbsp;&nbsp;|___Chats and Forums</option><option value="9">|&nbsp;&nbsp;&nbsp;|___Crafts</option><option value="10">|&nbsp;&nbsp;&nbsp;|___Criticism and Theory</option><option value="11">|&nbsp;&nbsp;&nbsp;|___Cultural Policy</option><option value="12">|&nbsp;&nbsp;&nbsp;|___Cultures and Groups</option><option value="13">|&nbsp;&nbsp;&nbsp;|___Design Arts</option><option value="14">|&nbsp;&nbsp;&nbsp;|___Education</option><option value="15">|&nbsp;&nbsp;&nbsp;|___Events</option><option value="16">|&nbsp;&nbsp;&nbsp;|___Humanities</option><option value="17">|&nbsp;&nbsp;&nbsp;|___Institutes</option><option value="18">|&nbsp;&nbsp;&nbsp;|___Job and Employment Resources</option><option value="26">|&nbsp;&nbsp;&nbsp;|___Local History</option><option value="19">|&nbsp;&nbsp;&nbsp;|___Museums, Galleries, and Centers</option><option value="20">|&nbsp;&nbsp;&nbsp;|___News and Media</option><option value="21">|&nbsp;&nbsp;&nbsp;|___Organizations</option><option value="22">|&nbsp;&nbsp;&nbsp;|___Performing Arts</option><option value="641">|&nbsp;&nbsp;&nbsp;|___Photography</option><option value="23">|&nbsp;&nbsp;&nbsp;|___Reference</option><option value="24">|&nbsp;&nbsp;&nbsp;|___Shopping and Services</option><option value="25">|&nbsp;&nbsp;&nbsp;|___Visual Arts</option><option value="419">|___Blogs</option><option value="550">|&nbsp;&nbsp;&nbsp;|___Blog Hosting</option><option value="420">|&nbsp;&nbsp;&nbsp;|___Business</option><option value="429">|&nbsp;&nbsp;&nbsp;|___Computer</option><option value="425">|&nbsp;&nbsp;&nbsp;|___Eclectic</option><option value="421">|&nbsp;&nbsp;&nbsp;|___Education</option><option value="692">|&nbsp;&nbsp;&nbsp;|___Home and Garden</option><option value="430">|&nbsp;&nbsp;&nbsp;|___Internet</option><option value="426">|&nbsp;&nbsp;&nbsp;|___Law</option><option value="422">|&nbsp;&nbsp;&nbsp;|___Library</option><option value="691">|&nbsp;&nbsp;&nbsp;|___Making Money</option><option value="466">|&nbsp;&nbsp;&nbsp;|___Money</option><option value="664">|&nbsp;&nbsp;&nbsp;|___Music</option><option value="431">|&nbsp;&nbsp;&nbsp;|___News</option><option value="427">|&nbsp;&nbsp;&nbsp;|___Personal</option><option value="423">|&nbsp;&nbsp;&nbsp;|___Politics</option><option value="424">|&nbsp;&nbsp;&nbsp;|___Science</option><option value="428">|&nbsp;&nbsp;&nbsp;|___Technology</option><option value="467">|&nbsp;&nbsp;&nbsp;|___Webmaster</option><option value="27">|___Business &amp; Economy</option><option value="518">|&nbsp;&nbsp;&nbsp;|___Affiliate Schemes</option><option value="519">|&nbsp;&nbsp;&nbsp;|___Buildings and Factories</option><option value="29">|&nbsp;&nbsp;&nbsp;|___Business Libraries</option><option value="28">|&nbsp;&nbsp;&nbsp;|___Business Resources</option><option value="30">|&nbsp;&nbsp;&nbsp;|___Business Schools</option><option value="36">|&nbsp;&nbsp;&nbsp;|___Business Training</option><option value="665">|&nbsp;&nbsp;&nbsp;|___Charity</option><option value="31">|&nbsp;&nbsp;&nbsp;|___Chats and Forums</option><option value="590">|&nbsp;&nbsp;&nbsp;|___Chemical Services and Supplies</option><option value="32">|&nbsp;&nbsp;&nbsp;|___Classifieds</option><option value="463">|&nbsp;&nbsp;&nbsp;|___Consultancy</option><option value="33">|&nbsp;&nbsp;&nbsp;|___Cooperatives</option><option value="34">|&nbsp;&nbsp;&nbsp;|___Directories of Services</option><option value="35">|&nbsp;&nbsp;&nbsp;|___Economics</option><option value="37">|&nbsp;&nbsp;&nbsp;|___Employment and Work</option><option value="688">|&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;|___Agencies</option><option value="38">|&nbsp;&nbsp;&nbsp;|___Ethics and Responsibility</option><option value="39">|&nbsp;&nbsp;&nbsp;|___Finance and Investment</option><option value="517">|&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;|___Debt Advice</option><option value="514">|&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;|___Insurance</option><option value="671">|&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;|___Business Insurance</option><option value="669">|&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;|___Car and Motorcycle Insurance</option><option value="670">|&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;|___Home Insurance</option><option value="652">


    need to extract string ___Insurance

    so from all code i need to extract like from

    &nbsp;|___Insurance</option><option value="671">

    highlighted in read is what i need i need to get them all out and populate them in list1

  2. #2
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: help extract string from richtextbox to listbox urgent

    Why are all your posts "urgent" ?

    You've been given enough examples of using InStr to be able to work this out for yourself.

  3. #3

    Thread Starter
    Banned
    Join Date
    Nov 2012
    Posts
    1,171

    Re: help extract string from richtextbox to listbox urgent

    you se need an example how to extract all them strings out usng ( for each ) command just like we do on list1 i dont no how to this is why i once learn this then il know
    i say its urgent because at the time i was working and without putting a fix to this i cant move onto next stage of coding other parts of the software mate.

  4. #4
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: help extract string from richtextbox to listbox urgent

    Not tested but I think it's something like this

    Code:
     Dim q1 as long, q2 As Long, q3 As Long
     Dim s1 As string
    
     q1 = 1
    
     For q1 = q1 to Len(HTML_String)
       q2 = InStr(q1, HTML_String, "|___")
      
       If q2 > 0 Then
         q3 = InStr(q2, HTML_String, "</option")
       Else
         Exit For 
       End If
    
       If q3 > 0 then
         q1 = q3
    
         s1 = Mid(HTML_String, q2 + 4, (q3 - (q2 + 4))
        
         List1.AddItem s1
       Else
         Exit For
       End If
     Next q1
    Last edited by jmsrickland; Jun 8th, 2013 at 02:51 PM.


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  5. #5
    Lively Member
    Join Date
    May 2009
    Location
    UK
    Posts
    72

    Re: help extract string from richtextbox to listbox urgent

    Try this :
    I just copied the text into a file called test.txt
    and created some controls.

    Code:
    Option Explicit
    
    ' Requires Component Microsoft Rich Texbox Control 6.0(sp6) - RICHTX32.OCX
    ' Requires Richtextbox RTBox
    ' Requires Listbox list1
    ' Requires test.txt
    
    Private Sub Form_Load()
    
        Call ReadFile(App.Path & "\" & "test.txt")
        Call ProcessRTBox
    
    End Sub
    
    Private Sub ProcessRTBox()
        Dim EachLine() As String
        Dim Pipe() As String
        Dim matchline As String
        Dim i As Integer
        Dim p As Integer
        Dim m As Integer
       
        ' split each line
        EachLine = Split(RTBox.Text, vbNewLine)
    
        For i = 0 To UBound(EachLine)
    
            ' split each line by '|'
            Pipe() = Split(EachLine(i), "|")
    
            For p = 0 To UBound(Pipe)
    
                ' find each matching line
                m = InStr(1, Pipe(p), "___")
                If m <> 0 Then
                    matchline = Pipe(p)
    
                    ' strip to just required text
                    If InStr(1, matchline, "<") <> 0 Then
                        matchline = Left$(matchline, InStr(1, matchline, "<") - 1)
                    End If
    
                    ' replace with real &
                    matchline = Replace$(matchline, "&amp;", "&")
    
                    ' add matching line to listbox
                    list1.AddItem matchline
    
                End If
    
            Next p
    
        Next i
    
    End Sub
    Private Sub ReadFile(ThisFile As String)
    
        Dim f As Integer
        Dim ReadLine As String
    
        f = FreeFile
    
        Open ThisFile For Input As #f
    
        Do Until EOF(f)
            Input #f, ReadLine
            RTBox.Text = RTBox.Text & ReadLine
        Loop
    
        Close #f
    
    End Sub

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