On visual studio visual basic. I am unable to change the progressBar maximum through codes

Harry 0 Reputation points
2023-07-12T15:08:05.28+00:00

Hello, my visual studio which I am using visual basic, I am unable to change the progress Bar maximum value through coding. For example, it reset to 100 when I try to change the maximum through numerical up down and a button. It was working before however I am not 100% sure what happened its not working anymore.

Developer technologies | VB
{count} votes

1 answer

Sort by: Most helpful
  1. Dewayne Basnett 1,381 Reputation points
    2023-07-12T16:22:16.8733333+00:00

    I tried to recreate the problem without luck.

            Dim tsk As Task
            tsk = Task.Run(Sub()
                               Me.BeginInvoke(Sub()
                                                  ProgressBar1.Minimum = 0
                                                  ProgressBar1.Maximum = 40
                                                  ProgressBar1.Value = 0
                                              End Sub)
    
                               For x As Integer = 1 To 60
                                   Threading.Thread.Sleep(20)
                                   Me.BeginInvoke(Sub()
                                                      ProgressBar1.Increment(1)
                                                  End Sub)
                               Next
    
                               Me.BeginInvoke(Sub()
                                                  ProgressBar1.Minimum = 0
                                                  ProgressBar1.Maximum = 10
                                                  ProgressBar1.Value = 0
                                              End Sub)
    
                               For x As Integer = 1 To 21
                                   Threading.Thread.Sleep(20)
                                   Me.BeginInvoke(Sub()
                                                      ProgressBar1.Increment(1)
                                                  End Sub)
                               Next
                           End Sub)
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.