8 Replies - 7293 Views - Last Post: 12 June 2011 - 07:37 AM Rate Topic: -----

#1 Chitra Sena  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 3
  • Joined: 04-February 11

find a word in a notepad file and return

Posted 04 February 2011 - 12:39 AM

i want to find a word in a notepad file. and return the next word of finding word. suppose
in a file contain some text like:
-----------------------------------------
hai my self harish.
i study in degree.
i saty in london.
and my age(24).
i like to paly cricket.
-----------------------------------------
in this file i want to find the text age and return the next word of finding is (24).

i want to collect the age in a text box.
---------------------------------------------------------------
any one please help me

Is This A Good Question/Topic? 0
  • +

Replies To: find a word in a notepad file and return

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9389
  • View blog
  • Posts: 35,261
  • Joined: 12-June 08

Re: find a word in a notepad file and return

Posted 04 February 2011 - 08:14 AM

Is this going to be a constant format? Will the word you are looking for change?

The quickest way is read the file in to a string (use stream reader), build your regex rule that fits the constant pattern, run the regex, see if you get back a return, and if you do great! If not.. do what ever.

An alternative would be to read through the stream reader's string with various string functions (find index of, split, etc) and going from there.
Was This Post Helpful? 1
  • +
  • -

#3 Tomination  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 22
  • Joined: 24-September 10

Re: find a word in a notepad file and return

Posted 04 February 2011 - 02:38 PM

You will want to research into the method of taking a value from a string, from its "Last Index"

For Example

If String.Contains(text) Then
String = String [Take from last index of], [1] 'the 1 means the next charactor after the index
End If

This post has been edited by Tomination: 04 February 2011 - 02:40 PM

Was This Post Helpful? 0
  • +
  • -

#4 Chitra Sena  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 3
  • Joined: 04-February 11

Re: find a word in a notepad file and return

Posted 05 February 2011 - 12:50 AM

View PostTomination, on 04 February 2011 - 02:38 PM, said:

You will want to research into the method of taking a value from a string, from its "Last Index"

For Example

If String.Contains(text) Then
String = String [Take from last index of], [1] 'the 1 means the next charactor after the index
End If



---------------------------------------------
i want to pick the next word. that means we search age then the next word is (24)in above example. i want to save the next word in a text box that means textbox contain 24.

i want to pick the next word. that means we search age then the next word is (24)in above example. i want to save the next word in a text box that means textbox contain 24.
Was This Post Helpful? 0
  • +
  • -

#5 Chitra Sena  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 3
  • Joined: 04-February 11

Re: find a word in a notepad file and return

Posted 05 February 2011 - 01:26 AM

View PostTomination, on 04 February 2011 - 02:38 PM, said:

You will want to research into the method of taking a value from a string, from its "Last Index"

For Example

If String.Contains(text) Then
String = String [Take from last index of], [1] 'the 1 means the next charactor after the index
End If

can you give me the proper code which code work in program
Was This Post Helpful? -1
  • +
  • -

#6 biggerB  Icon User is offline

  • If at first you donít succeed, call it version 1.0
  • member icon

Reputation: 80
  • View blog
  • Posts: 760
  • Joined: 11-June 10

Re: find a word in a notepad file and return

Posted 05 February 2011 - 09:51 AM

I think you are trying to get the work of a database out of a text file..

You Say when you search for "Age" you are returned the value of Age i.e. 24..

If this is correct you would be much better of using a database..

This post has been edited by biggerB: 05 February 2011 - 09:51 AM

Was This Post Helpful? 1
  • +
  • -

#7 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9389
  • View blog
  • Posts: 35,261
  • Joined: 12-June 08

Re: find a word in a notepad file and return

Posted 05 February 2011 - 10:59 AM

Just a heads up - "contains" returns a boolean, right? It says "heck yeah! that string you had me check on - yup, it resides in this other string!". There's no need to try and parse through the string you are searching for because YOU ALREADY HAVE THE SEARCH TERM! Now if you want the search term plus something else then yes.. read through the source string.

http://msdn.microsof...y/dy85x1sa.aspx
Was This Post Helpful? 0
  • +
  • -

#8 DawgPound1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 11-June 11

Re: find a word in a notepad file and return

Posted 11 June 2011 - 11:08 PM

 Dim a As String
        Dim b As String
        a = InputBox("Enter text to be found")
        b = InStr(RichTextBox1.Text, a)
        If b Then RichTextBox1.Focus()
        RichTextBox1.Selectionstart = b - 1
        RichTextBox1.SelectionLength = Len(a)
        If b = Nothing Then MsgBox("Text Is Not Found")


Should work
Was This Post Helpful? 0
  • +
  • -

#9 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,507
  • Joined: 16-March 11

Re: find a word in a notepad file and return

Posted 12 June 2011 - 07:37 AM

No code hand outs here brother, you gotta make an effort to learn. Show us what code you have already when you give it a shot, and we'll start from there.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1