1

Please I want to restart progress bar when [Progressbar.value = Maximum] and start again automatically from 1 to 10, Without Stopping or a specific time.

this is a code

Private Sub Timer19_Tick(sender As Object, e As EventArgs) Handles Timer19.Tick

    ProgressBar11.Increment(1)
    If ProgressBar11.Value = 2 Then
        Label23.Text = "KxStpDvDe7JMpDVCZBppQaMHaGSKqn8W3xY4qDXMSdUKdxitFPGw"
    End If
    If ProgressBar11.Value = 3 Then
        Label23.Text = "KzZrERxAiZgbHopAxUtQ6iDb4SMxZbgyeDmoK8diYgDf32c9Byrg"
    End If
    If ProgressBar11.Value = 4 Then
        Label23.Text = "L2FytfFKWuWyKunmGgwjFMMhUWaTnJP7qtnKENqwnacGhV6Z2rJv"
    End If
    If ProgressBar11.Value = 5 Then
        Label23.Text = "L4aFy9gsK7jy1YpdUvgsKdHrtdg2H5YC8R9s7UFx9oHVzEoLjqxR"
    End If
    If ProgressBar11.Value = 6 Then
        Label23.Text = "L5UKKWBUDM4z49hU1XTAAF2DKy7ycPXDeTSvQXDGJoSeCDSDFQJ7"
    End If
    If ProgressBar11.Value = 7 Then
        Label23.Text = "L55RuiA6EVm7GSfoLLJD8853LUovn79MR9RzGrMD2xQqsJ25DVx5"
    End If
    If ProgressBar11.Value = 8 Then
        Label23.Text = "KxSTtoDS7Wm2P6fGaxEWui1CD4cm47hoNGaoz8am6akHpsghmV1z"
    End If
    If ProgressBar11.Value = 9 Then
        Label23.Text = "L2eJLnMRfUt3fQPqGPFAdzK1x4xA28e4hRCDbQA8Wiij4piNkyig"
    End If
        If ProgressBar11.Value = ProgressBar11.Maximum Then
        Timer19.Stop()
        Label23.Text = "KyHGgvC28cxP9HpAMz6fnB5AHJo4QxG7j2HpF8VN1SB3KuJE9zp1"
        Label27.Enabled = True
    End If
End Sub
DerStarkeBaer
  • 669
  • 8
  • 28
  • What's happening? Have you debugged to check that Maximum is set and whether it ever meets your condition for stopping? – Andrew Mortimer Jun 08 '20 at 12:50
  • So do that then. What's the actual problem? – jmcilhinney Jun 08 '20 at 12:52
  • OT, that you have fields named `Timer19`, `Progressbar11`, `Label23` and `Label27` is a major concern. Firstly, how can you have 19 `Timers` and 11 `ProgressBars`? Secondly, try providing meaningful names for your controls, etc. – jmcilhinney Jun 08 '20 at 12:54
  • actually, is a big Application, so I have many timers and Progressbar in my code, so my problem is when progressbar arrives at maximum it stops, But I want to restart it from zero to the maximum automatically again and again .. many times, About names controls just I duplicate the labels and progressbars. – Jack Daniel Jun 08 '20 at 13:08
  • 1
    Hello, Welcome to Stack Overflow. If you want to move the progress bar continously, there is a style of progressbar called a marquee. You can use like this. ProgressBar11.MarqueeAnimationSpeed = 30 ProgressBar11.Style = ProgressBarStyle.Marquee – JohnnyJP Jun 08 '20 at 13:18
  • You could simplify your code with a select case statement and avoid all the Ifs. See https://learn.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/select-case-statement – JohnnyJP Jun 08 '20 at 13:21

1 Answers1

0

Please I want to restart progress bar when [Progressbar.value = Maximum] and start again automatically from 1 to 10, Without Stopping or a specific time.

Change:

If ProgressBar11.Value = ProgressBar11.Maximum Then
    Timer19.Stop()
    Label23.Text = "KyHGgvC28cxP9HpAMz6fnB5AHJo4QxG7j2HpF8VN1SB3KuJE9zp1"
    Label27.Enabled = True
End If

To:

If ProgressBar11.Value = ProgressBar11.Maximum Then
    Label23.Text = "KyHGgvC28cxP9HpAMz6fnB5AHJo4QxG7j2HpF8VN1SB3KuJE9zp1"
    Label27.Enabled = True
    ProgressBar11.Value = ProgressBar11.Minimum
End If

Though I agree with the others, there is probably much you could do to streamline your code by re-factoring it.

Having that many Timers on your form can is going to create a ton of events that have to be processed. If the Interval on these is rather small, your application is likely to become laggy. There are other ways to accomplish multiple progressbars, possibly a datagridview with custom drawing and only ONE Timer to force the datagridview to update all "progressbars" at the same time.

Idle_Mind
  • 38,363
  • 3
  • 29
  • 40