dcsimg
Results 1 to 5 of 5

Thread: Progress Bar Help

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2011
    Posts
    2

    Progress Bar Help

    Ive made a progress bar which does work but it finishs before my cmd command, How do i time it right???

    Code:
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
            Shell("cmd /c" & "Del ""Z:\Windows 7\$oem$\$$\Install\FirstLogOn\Anti-Virus Updates\Malwarebytes' Anti-Malware\Backup.exe"" & ROBOCOPY ""%ALLUSERSPROFILE%\Malwarebytes\Malwarebytes' Anti-Malware"" ""Z:\Windows 7\$oem$\$$\Install\FirstLogOn\Anti-Virus Updates\Malwarebytes' Anti-Malware"" /E /IS & ""C:\Program Files\WinRAR\rar.exe"" u -ep1 -r0 -z""Z:\Windows 7\$oem$\$$\Install\FirstLogOn\Anti-Virus Updates\Malwarebytes' Anti-Malware\info.txt"" -sfx ""Z:\Windows 7\$oem$\$$\Install\FirstLogOn\Anti-Virus Updates\Malwarebytes' Anti-Malware\Backup.rar"" ""Z:\Windows 7\$oem$\$$\Install\FirstLogOn\Anti-Virus Updates\Malwarebytes' Anti-Malware\""")
            Timer1.Start()
        End Sub
    Code:
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            ProgressBar1.Increment(1)
            If ProgressBar1.Value = ProgressBar1.Maximum Then
    
            End If
        End Sub
    End Class
    Thanks,

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    22,827

    Re: Progress Bar Help

    the problem is, there's no way to measure your process + set the progressbar accurately.

    have a look at:

    Process Class

    in particular the Start method + the StandardOutput property

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2011
    Posts
    2

    Re: Progress Bar Help

    Yea i see what you mean about you cant measure it.

    i could time how long the cmd takes to finish and add the seconds to the timer bar?
    Thanks,

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    103,886

    Re: Progress Bar Help

    Quote Originally Posted by nobodyknowz View Post
    Yea i see what you mean about you cant measure it.

    i could time how long the cmd takes to finish and add the seconds to the timer bar?
    Thanks,
    Just because it takes a particular amount of time on one occasion doesn't mean that it will take that much time on any other occasion.

    The appropriate thing to do in this scenario is to simply set the Style to Marquee, which produces what is sometimes called a "never-ending" progress bar or the like. You will have seen it yourself on many occasions. That will indicate to the user that something is happening without having to specify how far along that something is.

  5. #5
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    629

    Re: Progress Bar Help

    Or you can use an infinite loop.

    You basically do a 1 / X function to move on until the infinite.

    Code:
    Private prog As Double
    Private endprog As Integer
    
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            prog += 0.05
            ProgressBar1.Value = endprog - (1 / prog)
        End Sub
    End Class
    You basically subtract an infinitely smaller number. This works for a certain time, but at some time it will halt. (subtract values < 0,5)
    Set the prog and endprog accordingly to move from one percentage to the other. You can adjust the speed with the increment of prog.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width