Esato

Forum > General discussions > Non mobile discussion > string searching in VB.Net

Author string searching in VB.Net
luvsanro
P1
Joined: Jan 22, 2004
Posts: 156
From: SAN
PM, WWW
Posted: 2006-01-08 15:34
Reply with quoteEdit/Delete This PostPrint this post
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
P990
Joined: Nov 30, 2003
Posts: > 500
From: England
PM, WWW
Posted: 2006-01-08 16:08
Reply with quoteEdit/Delete This PostPrint this post
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. <BR> <BR>More info, including a couple more functions that you'll need, and some examples here: <BR> <BR><!-- BBCode auto-link start --><a href="http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=169&lngWId=10" rel="nofollow" target="_blank">http://www.planet-source-code[....]de.asp?txtCodeId=169&lngWId=10</a><!-- BBCode auto-link end --> <div class="sig">+7, -0 <!-- BBCode u2 Start --><a href="http://www.a-zott.com" rel="nofollow" target="_blank">A-Z of Trusted Traders</A><!-- BBCode u2 End --></div><!--s2--></td></tr><tr class="lk"> <td class="lkd" valign="top"><a href="//members.esato.com/Cycovision" class="lkb">Cycovision</a><br/><div style="white-space:pre"><img src="//www.esato.com/board/images/ranks/p990_5.gif" border="0" vspace="4" alt="P990"></div>Joined: Nov 30, 2003<br>Posts: > 500<br/>From: England<br/><a href="/board/sendpmsg.php?tousername=Cycovision" title="Send Private Message">PM</a>, <a href="/go.php?url=http://www.trentwebdesign.co.uk" target="_blank" rel="nofollow">WWW</a> </td><td valign="top"><a name="post1538818"></a> <div class="postsoptions"><img src="//www.esato.com/board/images/posticon.gif" alt="">Posted: 2006-01-08 16:13<br/><a href="#quoting" onclick="return quote('/board/reply.php?topic=112935&post=1538818&quote=1')" title="Quote post"><img src="//www.esato.com/board/images/quote_v2.png" border=0 alt="Reply with quote" width="39" height="14" class="pi"></a><a href="/board/editpost.php?post_id=1538818&topic=112935" title="Edit post"><img src="//www.esato.com/board/images/edit_v2.png" border=0 alt="Edit/Delete This Post" width="17" height="14" class="pi"></a><a href="javascript:void(0)" onclick="window.open('/board/printpost.php?post=1538818')" title="Print this post"><img src="//www.esato.com/board/images/print_v2.png" border="0" alt="Print this post" width="13" height="14" class="pi"></a> </div> 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. <BR> <BR>More info, including a couple more functions that you'll need, and some examples here: <BR> <BR><!-- BBCode auto-link start --><a href="http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=169&lngWId=10" rel="nofollow" target="_blank">http://www.planet-source-code[....]sp?txtCodeId=169&lngWId=10</a><!-- BBCode auto-link end --> <div class="sig">+7, -0 <!-- BBCode u2 Start --><a href="http://www.a-zott.com" rel="nofollow" target="_blank">A-Z of Trusted Traders</A><!-- BBCode u2 End --></div><!--s2--></td></tr><tr class="lk"> <td class="lkd" valign="top"><a href="//members.esato.com/luvsanro" class="lkb">luvsanro</a><br/><div style="white-space:pre"><img src="//www.esato.com/board/images/ranks/p1_5.gif" border="0" vspace="4" alt="P1"></div>Joined: Jan 22, 2004<br>Posts: 156<br/>From: SAN<br/><a href="/board/sendpmsg.php?tousername=luvsanro" title="Send Private Message">PM</a>, <a href="/go.php?url=http://www.devilsan.com/blog.html" target="_blank" rel="nofollow">WWW</a> </td><td valign="top"><a name="post1538819"></a> <div class="postsoptions"><img src="//www.esato.com/board/images/posticon.gif" alt="">Posted: 2006-01-08 16:13<br/><a href="#quoting" onclick="return quote('/board/reply.php?topic=112935&post=1538819&quote=1')" title="Quote post"><img src="//www.esato.com/board/images/quote_v2.png" border=0 alt="Reply with quote" width="39" height="14" class="pi"></a><a href="/board/editpost.php?post_id=1538819&topic=112935" title="Edit post"><img src="//www.esato.com/board/images/edit_v2.png" border=0 alt="Edit/Delete This Post" width="17" height="14" class="pi"></a><a href="javascript:void(0)" onclick="window.open('/board/printpost.php?post=1538819')" title="Print this post"><img src="//www.esato.com/board/images/print_v2.png" border="0" alt="Print this post" width="13" height="14" class="pi"></a> </div> can u please code it for me ?<!--s2--></td></tr><tr class="lk"> <td class="lkd" valign="top"><a href="//members.esato.com/Debu" class="lkb">Debu</a><br/><div style="white-space:pre"><img src="//www.esato.com/board/images/ranks/r600_5.gif" border="0" vspace="4" alt="R600"></div>Joined: Jan 15, 2003<br>Posts: > 500<br/>From: Colchester, UK<br/><a href="/board/sendpmsg.php?tousername=Debu" title="Send Private Message">PM</a></td><td valign="top"><a name="post1539530"></a> <div class="postsoptions"><img src="//www.esato.com/board/images/posticon.gif" alt="">Posted: 2006-01-09 12:17<br/><a href="#quoting" onclick="return quote('/board/reply.php?topic=112935&post=1539530&quote=1')" title="Quote post"><img src="//www.esato.com/board/images/quote_v2.png" border=0 alt="Reply with quote" width="39" height="14" class="pi"></a><a href="/board/editpost.php?post_id=1539530&topic=112935" title="Edit post"><img src="//www.esato.com/board/images/edit_v2.png" border=0 alt="Edit/Delete This Post" width="17" height="14" class="pi"></a><a href="javascript:void(0)" onclick="window.open('/board/printpost.php?post=1539530')" title="Print this post"><img src="//www.esato.com/board/images/print_v2.png" border="0" alt="Print this post" width="13" height="14" class="pi"></a> </div> 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. <BR> <BR> <BR><!-- BBCode Start --><IMG SRC="http://img202.imageshack.us/img202/4356/prg3ke.jpg" BORDER="0"><!-- BBCode End --> <BR> <BR>you can dowload the project file (Visual Studio 2005) from here: <BR> <BR><!-- BBCode auto-link start --><a href="http://rapidshare.de/files/10705075/Sample_String_Search.zip.html" rel="nofollow" target="_blank">http://rapidshare.de/files/10705075/Sample_String_Search.zip.html</a><!-- BBCode auto-link end --> <BR> <BR> <BR>here is the code: <BR> <BR> <BR><!-- BBCode Quote Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD>Quote:<HR></TD></TR><TR><TD><BLOCKQUOTE> <BR><!-- BBCode Start --><B> <BR><!-- BBCode Start --><I> <BR> <BR> <BR>Public Class Form1 <BR> <BR> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click <BR> Dim a, b As String <BR> ' Dim topicno As Long <BR> Dim i, k As Integer <BR> <BR> b = "" <BR> <BR> a = Me.url.Text <BR> For i = 0 To (a.Length - 1) <BR> If a(i) = "?" Then <BR> Exit For <BR> <BR> End If <BR> Next <BR> <BR> i = i + 7 <BR> For k = 0 To ((a.Length - 1) - (i)) <BR> b = b & a(i) <BR> i = i + 1 <BR> Next <BR> Me.Label3.Text = b <BR> <BR> <BR> End Sub <BR>End Class <BR></B><!-- BBCode End --> <BR></I><!-- BBCode End --> <BR> <BR> <BR></BLOCKQUOTE></TD></TR><TR><TD><HR></TD></TR></TABLE><!-- BBCode Quote End --> <BR> <BR>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. <div class="sig">Visit My Blog : <!-- BBCode u2 Start --><a href="http://debusinnovations.blogspot.com" rel="nofollow" target="_blank">Debu's Innovations</A><!-- BBCode u2 End --><BR><BR>'When nine hundred years old you will be, look as good, you will not' - Yoda</div><!--s2--></td></tr><tr class="lk"> <td class="lkd" valign="top"><a href="//members.esato.com/luvsanro" class="lkb">luvsanro</a><br/><div style="white-space:pre"><img src="//www.esato.com/board/images/ranks/p1_5.gif" border="0" vspace="4" alt="P1"></div>Joined: Jan 22, 2004<br>Posts: 156<br/>From: SAN<br/><a href="/board/sendpmsg.php?tousername=luvsanro" title="Send Private Message">PM</a>, <a href="/go.php?url=http://www.devilsan.com/blog.html" target="_blank" rel="nofollow">WWW</a> </td><td valign="top"><a name="post1539573"></a> <div class="postsoptions"><img src="//www.esato.com/board/images/posticon.gif" alt="">Posted: 2006-01-09 13:20<br/><a href="#quoting" onclick="return quote('/board/reply.php?topic=112935&post=1539573&quote=1')" title="Quote post"><img src="//www.esato.com/board/images/quote_v2.png" border=0 alt="Reply with quote" width="39" height="14" class="pi"></a><a href="/board/editpost.php?post_id=1539573&topic=112935" title="Edit post"><img src="//www.esato.com/board/images/edit_v2.png" border=0 alt="Edit/Delete This Post" width="17" height="14" class="pi"></a><a href="javascript:void(0)" onclick="window.open('/board/printpost.php?post=1539573')" title="Print this post"><img src="//www.esato.com/board/images/print_v2.png" border="0" alt="Print this post" width="13" height="14" class="pi"></a> </div> thats good but <BR>first i cant find the link where to click on rapidshare website .mail me [ ](remove spaces & add .com). <BR>Second i dont want to look inside a url in addess bar . <BR> <BR>i am trying to retieve the html from the webpage that is docStr where ,docStr is: <BR><!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD>Code:<HR></TD></TR><TR><TD><PRE> <BR>Dim docStr As mshtml.IHTMLElement <BR>docStr = docText.documentElement <BR></PRE></TD></TR><TR><TD><HR></TD></TR></TABLE><!-- BBCode End --> <BR> <BR>_________________ <BR> Download All MMS Clips<!-- BBCode u2 Start --><a href="http://www.smsbysan.8m.com" rel="nofollow" target="_blank">Here</A><!-- BBCode u2 End -->.First Subscribe to smsbysan group.<BR><BR><font size=-1>[ This Message was edited by: luvsanro on 2006-01-10 12:50 ]</font><!--s2--></td></tr><tr class="lk"> <td class="lkd" valign="top"><a href="//members.esato.com/Debu" class="lkb">Debu</a><br/><div style="white-space:pre"><img src="//www.esato.com/board/images/ranks/r600_5.gif" border="0" vspace="4" alt="R600"></div>Joined: Jan 15, 2003<br>Posts: > 500<br/>From: Colchester, UK<br/><a href="/board/sendpmsg.php?tousername=Debu" title="Send Private Message">PM</a></td><td valign="top"><a name="post1539579"></a> <div class="postsoptions"><img src="//www.esato.com/board/images/posticon.gif" alt="">Posted: 2006-01-09 13:49<br/><a href="#quoting" onclick="return quote('/board/reply.php?topic=112935&post=1539579&quote=1')" title="Quote post"><img src="//www.esato.com/board/images/quote_v2.png" border=0 alt="Reply with quote" width="39" height="14" class="pi"></a><a href="/board/editpost.php?post_id=1539579&topic=112935" title="Edit post"><img src="//www.esato.com/board/images/edit_v2.png" border=0 alt="Edit/Delete This Post" width="17" height="14" class="pi"></a><a href="javascript:void(0)" onclick="window.open('/board/printpost.php?post=1539579')" title="Print this post"><img src="//www.esato.com/board/images/print_v2.png" border="0" alt="Print this post" width="13" height="14" class="pi"></a> </div> 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. <BR> <!--s2--></td></tr><tr class="lk"><td colspan="2" class="gootd"> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- 728x90, created 3/6/10 --> <ins class="adsbygoogle" style="display:inline-block;width:728px;height:90px" data-ad-client="ca-pub-2559240025382447" data-ad-slot="2372587952"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </td></tr></table> <span style="float:left;font-size:xx-small">Access the forum with a mobile phone via <b>esato.mobi</b><br /> <form action="/board/search.php" method="get"><input type="text" size="20" value="" name="q" /><input type="hidden" name="t" value="112935" /><input type="hidden" name="asp" value="1" /><input type="submit" value="Search thread" /></form></span> <div align="right"> <div class="forulnewreply"> <ul class="forul"> <li><a href="/board/newtopic.php?forum=22">New Topic</a></li> <li><a href="/board/reply.php?topic=112935&forum=22">Reply</a></li> </ul> </div> <CENTER><a href="/board/topicadmin.php?mode=lock&topic=112935&forum=22"><IMG SRC="//www.esato.com/board/images/lock_topic.gif" ALT="Lock this Topic" BORDER=0></a> <a href="/board/topicadmin.php?mode=move&topic=112935&forum=22"><IMG SRC="//www.esato.com/board/images/move_topic.gif" ALT="Move this Topic" BORDER=0></a> <a href="/board/topicadmin.php?mode=del&topic=112935&forum=22"><IMG SRC="//www.esato.com/board/images/del_topic.gif" ALT="Delete this Topic" BORDER=0></a></CENTER> </td></tr></table><!--s1--> </div><!-- maincontent --> <div class="botmenu"> <div><a href="/archive/" style="text-align:left;float:left">Archive</a></div> <a href="/about/sitemap.php">Sitemap</a> <span class="sep">|</span> <a href="/contact/">Contact</a> <span class="sep">|</span> <a href="/about/">About</a>    </div> </div><!-- indreramme --> </div><!-- ytterramme --> <a href="#" id="dingi"></a><script type="text/javascript" src="//www.esato.com/jquery-1.4.min.js"></script><script type="text/javascript"> var ajaxserver = '/board'; </script><script type="text/javascript" src="//www.esato.com/board/pmcheck.js"></script><script type="text/javascript" src="/board/imgdim.js"></script><script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-248517-1', 'auto'); ga('send', 'pageview'); </script> <script type="text/javascript"> if(typeof jQuery == 'undefined'){ document.write(unescape("%3Cscript src='//www.esato.com/jquery-1.4.min.js' type='text/javascript'%3E%3C/script%3E")); } window.fbAsyncInit = function() { FB.init({appId: "157562974258194", status: true, cookie: true, xfbml: true}); FB.Event.subscribe('edge.create', function(liked){ $.getJSON('//www.esato.com/fblike.php?url=' + escape(liked)); }); }; (function() { var e = document.createElement("script"); e.async = true; e.src = document.location.protocol + "//connect.facebook.net/en_US/all.js"; document.getElementById("fb-root").appendChild(e); }()); </script></body> </html>