title: Visual Studio 2012 - Progress Bar
body: <p>I am trying to get my progress bar all the way to 100% but it updates to around 85-95% and then opens my next form. Could someone guide me as to what I'm doing incorrectly? I have tried to edit the step and also the sleep count but I can just manage to get it to near the end of the progress bar. Is there some code interfering with the progress bar?</p>
  
  <pre><code>Public Class LoginForm
  '
  'This specifies the default value for the login attempt
  Dim Attempt = 0
  Public Function checkinput() As Boolean
      '
      'This is the default username
      Dim Uname = "Niral Mehta"
      '
      'This is the default password
      Dim pword = "Ban4na"
      '
      'This assigns the value of the Username to the UserText.text variable
      Dim Username = UserText.Text
      '
      'This assigns the value of the Password to the PassText.text variable
      Dim Password = PassText.Text
      '
      'Here the Username and password are being assigned the values defined above, if the user input correctly matches the defined values then it returns as true
      If Username = Uname And Password = pword Then
          Return True
      Else
          '
          'If the user fails to put in the correct values on the third attempt then the program automatically shuts down after warning them
          If Attempt = 3 Then
              MsgBox("You have failed to login correctly three times, this program will shut down as a security measure", MsgBoxStyle.OkOnly)
              Me.Close()
              Return False
          End If
          Attempt = Attempt + 1
          MsgBox("Incorrect username and/or password", MsgBoxStyle.OkOnly)
          Return False
      End If
  End Function
  
  Private Sub KillProcess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KillProcess.Click
      '
      'When the end program button is clicked, a message box will pop up and give the options to end the program
      If MsgBox("Are you sure you want to quit?", MsgBoxStyle.YesNo) = DialogResult.Yes Then
          Me.Close()
      End If
  End Sub
  
  Private Sub PassText_TextChanged(sender As Object, e As EventArgs) Handles PassText.TextChanged
      '
      'This hides the password characters 
      PassText.PasswordChar = "#"
  
      'This sets the character length for a password 
      '
      PassText.MaxLength = 8
  End Sub
  
  Private Sub UserText_TextChanged(sender As Object, e As EventArgs) Handles UserText.TextChanged
      '
      'This sets the character length for a username
      UserText.MaxLength = 14
  End Sub
  
  Private Sub StartNextForm_Click(sender As Object, e As EventArgs) Handles StartNextForm.Click
      If checkinput() Then
          With LoginProgress
              .Visible = True
              .Step = 2
              .Maximum = 101
              .Style = ProgressBarStyle.Blocks
              .Value = 0
          End With
          Do
              System.Threading.Thread.Sleep(100)
              LoginProgress.PerformStep()
          Loop Until LoginProgress.Value &gt;= LoginProgress.Maximum
          FrmMain.Show()
          Me.Hide()
      End If
  End Sub
  </code></pre>