Author |
string searching in VB.Net |
luvsanro Joined: Jan 22, 2004 Posts: 156 From: SAN PM, WWW
|
hi guyz whats up, need some help on topic subjected .
i want to search for a string within another string
e.g.<link rel="alternate" type="application/rss+xml" title="Mt RSS Feed" href="smsbysan.8m.com" >i want to get the title string & the href string.
_________________
Download All MMS Clips[url=www.smsbysan.8m.com]Here[/url].First Subscribe to smsbysan group.
[ This Message was edited by: luvsanro on 2006-01-08 14:39 ] |
|
Cycovision Joined: Nov 30, 2003 Posts: > 500 From: England PM, WWW
|
You'll need to use the 'indexof' and 'substring' functions. 'indexof' finds the excact text that you want (eg. ) and returns it's numerical position in the string. You can then use this value with 'substring' to cut out the info that you want and place it in a new variable.
More info, including a couple more functions that you'll need, and some examples here:
http://www.planet-source-code[....]de.asp?txtCodeId=169&lngWId=10
|
Cycovision Joined: Nov 30, 2003 Posts: > 500 From: England PM, WWW
|
You'll need to use the 'indexof' and 'substring' functions. 'indexof' finds the excact text that you want (eg. <title>) and returns it's numerical position in the string. You can then use this value with 'substring' to cut out the info that you want and place it in a new variable.
More info, including a couple more functions that you'll need, and some examples here:
http://www.planet-source-code[....]sp?txtCodeId=169&lngWId=10
|
luvsanro Joined: Jan 22, 2004 Posts: 156 From: SAN PM, WWW
|
can u please code it for me ? |
Debu Joined: Jan 15, 2003 Posts: > 500 From: Colchester, UK PM |
I whipped up this sample application for you to explain the string searching using looping structures in vb. In this tiny program, you enter the Esato URL, ad it will tell you the topc ID.
you can dowload the project file (Visual Studio 2005) from here:
http://rapidshare.de/files/10705075/Sample_String_Search.zip.html
here is the code:
Quote:
|
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a, b As String
' Dim topicno As Long
Dim i, k As Integer
b = ""
a = Me.url.Text
For i = 0 To (a.Length - 1)
If a(i) = "?" Then
Exit For
End If
Next
i = i + 7
For k = 0 To ((a.Length - 1) - (i))
b = b & a(i)
i = i + 1
Next
Me.Label3.Text = b
End Sub
End Class
|
|
I know this isnt the best way, but i'm more of a C# guy, VB isn't exactly my strong point, and anyways this does the trick.
Visit My Blog : Debu's Innovations'When nine hundred years old you will be, look as good, you will not' - Yoda |
luvsanro Joined: Jan 22, 2004 Posts: 156 From: SAN PM, WWW
|
thats good but
first i cant find the link where to click on rapidshare website .mail me [ ](remove spaces & add .com).
Second i dont want to look inside a url in addess bar .
i am trying to retieve the html from the webpage that is docStr where ,docStr is:
Code:
|
Dim docStr As mshtml.IHTMLElement
docStr = docText.documentElement
|
|
_________________
Download All MMS ClipsHere.First Subscribe to smsbysan group.
[ This Message was edited by: luvsanro on 2006-01-10 12:50 ] |
Debu Joined: Jan 15, 2003 Posts: > 500 From: Colchester, UK PM |
On the rapidshare page that opens click the 'free' button near the bottom of the page, I will email you the file in any case by this evening. You can use this same method for an html doctype, just parse the html to text, but as I said this isn't the most efficient method, ideally you could make a class which would search only via the line number on the html page. If you are using 2005, there are system.xml, and system.web classes where you could make a repeating node element and search.
|
|