Results 1 to 6 of 6

Thread: Progress Bar Help

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2008
    Posts
    3

    Progress Bar Help

    hi, can someone please help me, i have added a progress bar and i added a start and stop button, the start is working fine, but i dont know the coding for the stop button could someone please tell me the coding for the stop button please, here is my codng for the start button, any help would be appreciated, thanks

    Code:
    Public Class Form1
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim num As Integer
            For num = 1 To 100
                ProgressBar1.Value = num
                lblCounter.Text = Format(num / 100, "p")
                lblCounter.Refresh()
                Threading.Thread.Sleep(100)
                lblvfound.Visible = True
    
                lblvfound2.Visible = False
                If lblCounter.Text = "100.00 %" Then
                    lblvfound2.Visible = True
                ElseIf lblCounter.Text = "0.10 %" Then
                    lblvfound.Visible = True
                End If
    
            Next
            MsgBox("The Virus Scanning Is Complete", MsgBoxStyle.OkOnly)
    
        End Sub
    
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    
        End Sub

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Progress Bar Help

    Thread moved from Classic Visual Basic (VB6 and earlier) forum to VB.Net (VB2002 and later) forum.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2008
    Posts
    3

    Re: Progress Bar Help

    please, does anyone know the coding for the stop button?

  4. #4
    Fanatic Member
    Join Date
    Feb 2006
    Posts
    607

    Re: Progress Bar Help

    I dont know if this will work, but you can create an event for the stop.

    Once the stop button is clicked you raise that event.

  5. #5
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: Progress Bar Help

    Are you trying to Stop the for - next loop in button1? As usual I don't get the question.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  6. #6
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,423

    Re: Progress Bar Help

    vb Code:
    1. Public Class Form1
    2.  
    3.     private cancelled as boolean = false
    4.  
    5.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    6.         Dim num As Integer
    7.         For num = 1 To 100
    8.  
    9.             if cancelled then
    10.                exit sub
    11.             end if
    12.  
    13.             ProgressBar1.Value = num
    14.             lblCounter.Text = Format(num / 100, "p")
    15.             lblCounter.Refresh()
    16.             Threading.Thread.Sleep(100)
    17.             lblvfound.Visible = True
    18.  
    19.             lblvfound2.Visible = False
    20.             If lblCounter.Text = "100.00 %" Then
    21.                 lblvfound2.Visible = True
    22.             ElseIf lblCounter.Text = "0.10 %" Then
    23.                 lblvfound.Visible = True
    24.             End If
    25.  
    26.         Next
    27.         MsgBox("The Virus Scanning Is Complete", MsgBoxStyle.OkOnly)
    28.  
    29.     End Sub
    30.  
    31.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    32.         cancelled = true
    33.     End Sub
    34.  
    35. end class

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