Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: String in open dialog  (Read 3520 times)

0 Members and 1 Guest are viewing this topic.

almn

  • Guest
String in open dialog
« on: November 05, 2006, 08:38:48 AM »
Hello,

I would like to know how to create a vb.net program that allows the user to select a file (open dialog) and then check if the string in the textbox txtString is present in the selected file. Finally all those actions should be executed when the button btnstart is pushed and if the string is found in the file create a Messagebox saying that the message was found else create a messagebox saying that the string wasn't found. I know how to do all of it exept for checking if the string is present.

Thanks

Almn

almn

  • Guest
Re: String in open dialog
« Reply #1 on: November 06, 2006, 06:04:54 PM »
ok, I've got how to check if string a is present in string b however I don't know how to do that with the files, can anybody tell me how to get the content of a text file in a variable so that I can do that . Here is what I have so far:
Code: [Select]
Dim i As Integer = str.IndexOf("This")
'If it returns -1 it means that no matches for the specified string was found.
If Not i = -1 Then
MessageBox.Show(" the string is in here!")
Else
MessageBox.Show(" the string is not in here!")
End If
Thanks

Al968