Click here to Skip to main content
13,054,329 members (122,347 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
Hi Friends,

I have an textbox and an search button when i am click on search button its match the textbox text in text file and if text is match then its show next word in the messagebox or label.

how i can do this thing?

right now i am using the follwing code which is help to match the textbox value in the textfield but how i can got the next word form the text file can any one help me??

Dim InputStr As String = SearchTextbox.Text
       For Each FileStr As String In IO.Directory.GetFiles("D:\", "*.txt")
           If IO.File.ReadAllText(FileStr).IndexOf(InputStr) >= 0 Then


               'SearchTextbox.Text = IO.File.ReadAllText(InputStr)

               MessageBox.Show("Text Match Dome.", "Text Match", MessageBoxButton.OK, MessageBoxImage.Information)
           End If
       Next
Posted 27-Sep-12 2:49am
Comments
Sergey Alexandrovich Kryukov 27-Sep-12 13:12pm
   
How on Earth this can be related to WPF?
--SA
Sergey Alexandrovich Kryukov 27-Sep-12 13:16pm
   
And what did you try? What you show is pretty unrelated to the problem, as well as WPF. You are not even trying to analyze the result it ReadAllText...
--SA
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Without your if operator, assign the result of ReadAllText to some string variable and parse it to get what you need. Start with System.String.Split:
http://msdn.microsoft.com/en-us/library/system.string.split.aspx[^].

—SA
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Here is the code that i used..

Dim fileAs String = Application.StartupPath & "\file.txt"
 
      If System.IO.File.Exists(file.txt) = True Then
          Dim objReader As New System.IO.StreamReader(file.txt)
          file= objReader.ReadToEnd
 
         ' Or you can use objReader.ReadLine '
      Else
          MsgBox("File does not exists")
          Exit Sub
      End If
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 27 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100