Results 1 to 9 of 9

Thread: Some simple questions

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2009
    Posts
    22

    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.

  2. #2
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    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:
    1. If ProgressBar1.Value = 1000 Then
    2.      MessageBox.Show("Success")
    3. End If

    You could then set an integer variable at class scope that will keep track of the seconds.

    vb Code:
    1. 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:

    vb Code:
    1. _TimePassed += 1

    That way, each second, it gets + 1. Then check within the code:

    vb Code:
    1. If ProgressBar1.Value = 1000 Or _TimePassed = 10 Then
    2.      MessageBox.Show("Success")
    3. End If
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Dec 2009
    Posts
    22

    Re: Some simple questions

    Quote Originally Posted by weirddemon View Post
    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:
    1. If ProgressBar1.Value = 1000 Then
    2.      MessageBox.Show("Success")
    3. End If

    You could then set an integer variable at class scope that will keep track of the seconds.

    vb Code:
    1. 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:

    vb Code:
    1. _TimePassed += 1

    That way, each second, it gets + 1. Then check within the code:

    vb Code:
    1. If ProgressBar1.Value = 1000 Or _TimePassed = 10 Then
    2.      MessageBox.Show("Success")
    3. End If
    Yeah, that's what I was looking for. Thanks. Any clues on how to do the second thing I asked?

  4. #4
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    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

  5. #5
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    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

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Dec 2009
    Posts
    22

    Re: Some simple questions

    Quote Originally Posted by weirddemon View Post
    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.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Dec 2009
    Posts
    22

    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?

  8. #8
    Addicted Member spyk3's Avatar
    Join Date
    Apr 2009
    Location
    Dothan, AL
    Posts
    218

    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

  9. #9
    Addicted Member spyk3's Avatar
    Join Date
    Apr 2009
    Location
    Dothan, AL
    Posts
    218

    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
  •  



Click Here to Expand Forum to Full Width