| | |
Find Functionality
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Apr 2008
Posts: 54
Reputation:
Solved Threads: 5
Hai all,
in my appliction Im writing functionality to find keywords entered by user
if keyword found i need to return the 10 words before keyword and 10 words after keywords, Im able to find the keywords using Instr method.. Im not getting how to get 10 words Before and after keywords.. Any one hae idea? if you have sample code Then it would more help full
Thanks In advance.
in my appliction Im writing functionality to find keywords entered by user
if keyword found i need to return the 10 words before keyword and 10 words after keywords, Im able to find the keywords using Instr method.. Im not getting how to get 10 words Before and after keywords.. Any one hae idea? if you have sample code Then it would more help full
Thanks In advance.
Last edited by Pgmer; Jul 1st, 2008 at 7:46 am.
•
•
Join Date: Dec 2002
Posts: 461
Reputation:
Solved Threads: 56
Here is one way.
Three textboxes and button.
Three textboxes and button.
VB.NET Syntax (Toggle Plain Text)
Public Class Form1 Dim KeyWord As String = "aid" Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load TextBox1.Text = "Now is the time for all good men to come to the aid of their country the quick brown fox jumps over the lazy dog" End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim Ary() As String = Nothing Ary = TextBox1.Text.Split(" ") Dim index As Integer = 0 For index = 0 To UBound(Ary) If Ary(index) = KeyWord Then Exit For End If Next If index <= UBound(Ary) Then For i As Integer = index - 10 To index - 1 TextBox2.Text &= Ary(i) & " " Next For i As Integer = index + 1 To index + 10 TextBox3.Text &= Ary(i) & " " Next End If End Sub End Class
Wayne
It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
•
•
Join Date: Jun 2008
Posts: 2
Reputation:
Solved Threads: 1
Hum, That's good and easy coding stuffs, thanks for sharing man.
www.cygnet-infotech.com
www.cygnet-infotech.com
Not clear -- you want to find 10 words before, and 10 after any keyword, but only if the words are inside a paragraph?
Like, the keyword is the firs word in a given paragraph, so you'd only want 10 words after?
You just need to search for the line break before, and the line break after, then only search inside that block. Then, search for 10 space characters before and after, and include every character between those two indexes.
Like, the keyword is the firs word in a given paragraph, so you'd only want 10 words after?
You just need to search for the line break before, and the line break after, then only search inside that block. Then, search for 10 space characters before and after, and include every character between those two indexes.
•
•
Join Date: Dec 2002
Posts: 461
Reputation:
Solved Threads: 56
Try this then:
VB.NET Syntax (Toggle Plain Text)
Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load TextBox1.Text = "The quick brown fox jumps over the lazy dog" & vbNewLine TextBox1.Text &= "Now is the time for all good men to come to the aid of their country" & vbNewLine TextBox1.Text &= "This is a test for finding all." End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim ary As String() ary = TextBox1.Text.Split(vbNewLine) For index As Integer = 0 To UBound(ary) If ary(index).IndexOf("the") <> -1 Then MessageBox.Show(ary(index)) End If Next End Sub End Class
Wayne
It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
•
•
Join Date: Apr 2008
Posts: 54
Reputation:
Solved Threads: 5
Thank u both ken sharpe and waynespangler for ur response.
what exactly i want is .
Say in document there may be 100 paragrphs out of which only 10 paragraph contains the keyword for which im searching for. i have to return those 10 paragraphs which have the keyword. if keyword is at start of paragraph then it should pick that paragraph and keep serching for the next paragraphs in which key word is there untill it reaches the end of document.
Hope this is clear...
Pls share ur ideas.
Thanks
what exactly i want is .
Say in document there may be 100 paragrphs out of which only 10 paragraph contains the keyword for which im searching for. i have to return those 10 paragraphs which have the keyword. if keyword is at start of paragraph then it should pick that paragraph and keep serching for the next paragraphs in which key word is there untill it reaches the end of document.
Hope this is clear...
Pls share ur ideas.
Thanks
![]() |
Similar Threads
- functionality of board [code attached = please check this question] (Java)
- Search weirdness (doesn't find all posts) (DaniWeb Community Feedback)
- E-business tool needed (eCommerce)
- Trying to get the SMTP functionality for mediawiki to work. (PHP)
- Newbie e-mail functionality question (MS Access and FileMaker Pro)
- arrays and functionality of the program... (C++)
- Need to find a solution similar to Yahoo News related search (JavaScript / DHTML / AJAX)
- cannot find server - Microsoft Internet Explorer afterdownloading Win Service pack 2 (Networking Hardware Configuration)
- find 4 you (Windows NT / 2000 / XP)
Other Threads in the VB.NET Forum
- Previous Thread: New Appl for Windows Mobile 6 Phones
- Next Thread: Resource transformation for file filename.resx failed.Invalid Resx input
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
.net 2005 2008 access account application arithmetic array arrays basic bing button buttons c# center check checkbox code combobox component convert crystalreport data database datagrid datagridview date dissertation dissertations dropdownlist excel fade file-dialog ftp generatetags google gridview hardcopy images inline input insert intel internet listview mobile monitor ms net networking objects output passingparameters peertopeervideostreaming picturebox picturebox1 port print printing problem problemwithinstallation project remove save searchbox searchvb.net select serial server shutdown soap sorting survey table tcp temperature text textbox timer toolbox trim update updown user validation vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web winforms wpf





