|
-
Feb 17th, 2010, 09:42 PM
#1
Thread Starter
Junior Member
Some simple questions
Hello, I'm trying to improove a little an application I made a while ago and I need some help. It would be best if you posted the procedure of making the code instead of pasting one so I could learn how it works.
I need to do a MessageBox.Show when ProgressBar1.Value = 1000 or after 10 seconds Button1 was clicked. For the second method, I thought of making a loop but I didn't know how to.
I also need to search a string in a file (The string to search will be the text which was entered in a TextBox) and do different things depending on if the string was found or not.
Last edited by hotlip1; Feb 17th, 2010 at 09:45 PM.
-
Feb 17th, 2010, 10:10 PM
#2
Re: Some simple questions
I assume you're increasing the ProgressBar's value in another way, yes?
Either way, in the Timer's Tick event, you can check if the Value of the ProgressBar is 1000.
vb Code:
If ProgressBar1.Value = 1000 Then MessageBox.Show("Success") End If
You could then set an integer variable at class scope that will keep track of the seconds.
vb Code:
Dim _TimePassed As Integer = 0
If your timer is set to 1000 (1 second), each tick will be 1 second. Then, in the same event, at the top of it, you could add:
That way, each second, it gets + 1. Then check within the code:
vb Code:
If ProgressBar1.Value = 1000 Or _TimePassed = 10 Then MessageBox.Show("Success") End If
CodeBank contributions: Process Manager, Temp File Cleaner
 Originally Posted by SJWhiteley
"game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....
-
Feb 18th, 2010, 11:59 AM
#3
Thread Starter
Junior Member
Re: Some simple questions
 Originally Posted by weirddemon
I assume you're increasing the ProgressBar's value in another way, yes?
Either way, in the Timer's Tick event, you can check if the Value of the ProgressBar is 1000.
vb Code:
If ProgressBar1.Value = 1000 Then
MessageBox.Show("Success")
End If
You could then set an integer variable at class scope that will keep track of the seconds.
vb Code:
Dim _TimePassed As Integer = 0
If your timer is set to 1000 (1 second), each tick will be 1 second. Then, in the same event, at the top of it, you could add:
That way, each second, it gets + 1. Then check within the code:
vb Code:
If ProgressBar1.Value = 1000 Or _TimePassed = 10 Then
MessageBox.Show("Success")
End If
Yeah, that's what I was looking for. Thanks. Any clues on how to do the second thing I asked?
-
Feb 18th, 2010, 12:04 PM
#4
Re: Some simple questions
You can use a streamreader to read the file into a string variable then use Contains method to look for the search string.
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Feb 18th, 2010, 12:12 PM
#5
Re: Some simple questions
Yeah, that's what I was looking for. Thanks. Any clues on how to do the second thing I asked?
The second thing wasn't there originally 
But Gary's idea should work
CodeBank contributions: Process Manager, Temp File Cleaner
 Originally Posted by SJWhiteley
"game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....
-
Feb 18th, 2010, 04:51 PM
#6
Thread Starter
Junior Member
Re: Some simple questions
 Originally Posted by weirddemon
The second thing wasn't there originally
But Gary's idea should work 
You mean because I edited my post?
Lol, I just edited it to correct some grammar but the question was always there.
-
Feb 18th, 2010, 05:37 PM
#7
Thread Starter
Junior Member
Re: Some simple questions
So to search for a string (TextBox1.Text) in a file i thought of this:
Code:
Dim readFile As System.IO.StreamReader
readFile = _
My.Computer.FileSystem.OpenTextFileReader("<File Directory>")
Dim fileString As String
fileString = fileReader.ReadLine()
But where should the TextBox1.Text go in that code?
-
Feb 18th, 2010, 06:01 PM
#8
Addicted Member
Re: Some simple questions
Well that's a good snippet u found there but is only going to read a file loaded,
check this out. It should help you understant streamreader class a lil better.
And fyi, it sounds like you might want to look at some of the msdn tutorials on building forms in visual studio. Just a suggestion, no offesnse ment, by all means, knowledge is always only a question away.
Once you understand how the class actually works, u'll better understand on how to change out the variables.
and if i'm not mistakin, i'll have to look, i think there is actually a textreader subclass just for reading textbox strins n such
Last edited by spyk3; Feb 18th, 2010 at 06:07 PM.
-
Feb 18th, 2010, 06:11 PM
#9
Addicted Member
Re: Some simple questions
I cant find a textreader class, and i think streamreader wrong way to go because it actually reads from memory (ie you would need to save your textbox to a file then recall it)
why wouldn't textbox.text.contains work?
I think what your asking for initially is regular expressions which is a pain but u can get more info here
http://regexlib.com/
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|