06-18-2012, 01:53 PM
I am trying to make an app that will search multiple files for one string. I am able to make it search an individual file with the following code:
Dim numberinfile As String = IO.File.ReadAllText("C:\Documents and Settings\Owner\My Documents\Downloads\example.txt")
Dim target_string As String = TextBox1.Text
If numberinfile.IndexOf(target_string) <> -1 Then
MsgBox(TextBox1.Text & " was found ")
Else
MsgBox(TextBox1.Text & " was NOT found ")
End If
I just want to take out example.txt and insert an *.txt, which in python would translate into a wild card. I was told about using Directory.GetFiles to get a list of files within a directory and then loop it until all files are read in that directory. I have no idea how to do that and the person didn't really explain much other than give me that piece of information. I only know so much about VB since I took a course in high school on the basics and my college didn't bring VB up in any courses. If there is any additional resources I could use for VB knowledge feel free to post them here. Thanks
Dim numberinfile As String = IO.File.ReadAllText("C:\Documents and Settings\Owner\My Documents\Downloads\example.txt")
Dim target_string As String = TextBox1.Text
If numberinfile.IndexOf(target_string) <> -1 Then
MsgBox(TextBox1.Text & " was found ")
Else
MsgBox(TextBox1.Text & " was NOT found ")
End If
I just want to take out example.txt and insert an *.txt, which in python would translate into a wild card. I was told about using Directory.GetFiles to get a list of files within a directory and then loop it until all files are read in that directory. I have no idea how to do that and the person didn't really explain much other than give me that piece of information. I only know so much about VB since I took a course in high school on the basics and my college didn't bring VB up in any courses. If there is any additional resources I could use for VB knowledge feel free to post them here. Thanks