|
-
Jun 8th, 2013, 07:29 AM
#1
Thread Starter
Banned
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 & Humanities</option><option value="2">| |___Art History</option><option value="3">| |___Art Weblogs</option><option value="4">| |___Artists</option><option value="5">| |___Awards</option><option value="6">| |___Booksellers</option><option value="7">| |___Censorship</option><option value="8">| |___Chats and Forums</option><option value="9">| |___Crafts</option><option value="10">| |___Criticism and Theory</option><option value="11">| |___Cultural Policy</option><option value="12">| |___Cultures and Groups</option><option value="13">| |___Design Arts</option><option value="14">| |___Education</option><option value="15">| |___Events</option><option value="16">| |___Humanities</option><option value="17">| |___Institutes</option><option value="18">| |___Job and Employment Resources</option><option value="26">| |___Local History</option><option value="19">| |___Museums, Galleries, and Centers</option><option value="20">| |___News and Media</option><option value="21">| |___Organizations</option><option value="22">| |___Performing Arts</option><option value="641">| |___Photography</option><option value="23">| |___Reference</option><option value="24">| |___Shopping and Services</option><option value="25">| |___Visual Arts</option><option value="419">|___Blogs</option><option value="550">| |___Blog Hosting</option><option value="420">| |___Business</option><option value="429">| |___Computer</option><option value="425">| |___Eclectic</option><option value="421">| |___Education</option><option value="692">| |___Home and Garden</option><option value="430">| |___Internet</option><option value="426">| |___Law</option><option value="422">| |___Library</option><option value="691">| |___Making Money</option><option value="466">| |___Money</option><option value="664">| |___Music</option><option value="431">| |___News</option><option value="427">| |___Personal</option><option value="423">| |___Politics</option><option value="424">| |___Science</option><option value="428">| |___Technology</option><option value="467">| |___Webmaster</option><option value="27">|___Business & Economy</option><option value="518">| |___Affiliate Schemes</option><option value="519">| |___Buildings and Factories</option><option value="29">| |___Business Libraries</option><option value="28">| |___Business Resources</option><option value="30">| |___Business Schools</option><option value="36">| |___Business Training</option><option value="665">| |___Charity</option><option value="31">| |___Chats and Forums</option><option value="590">| |___Chemical Services and Supplies</option><option value="32">| |___Classifieds</option><option value="463">| |___Consultancy</option><option value="33">| |___Cooperatives</option><option value="34">| |___Directories of Services</option><option value="35">| |___Economics</option><option value="37">| |___Employment and Work</option><option value="688">| | |___Agencies</option><option value="38">| |___Ethics and Responsibility</option><option value="39">| |___Finance and Investment</option><option value="517">| | |___Debt Advice</option><option value="514">| | |___Insurance</option><option value="671">| | | |___Business Insurance</option><option value="669">| | | |___Car and Motorcycle Insurance</option><option value="670">| | | |___Home Insurance</option><option value="652">
need to extract string ___Insurance
so from all code i need to extract like from
|___Insurance</option><option value="671">
highlighted in read is what i need i need to get them all out and populate them in list1
-
Jun 8th, 2013, 09:48 AM
#2
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.
-
Jun 8th, 2013, 02:01 PM
#3
Thread Starter
Banned
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.
-
Jun 8th, 2013, 02:44 PM
#4
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.
-
Jun 9th, 2013, 10:05 PM
#5
Lively Member
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, "&", "&")
' 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|