dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Progress bar

  1. #1
    Join Date
    May 2007
    Location
    SC
    Posts
    4

    Progress bar

    Hello all!

    I am using vb.net 2005 and I am trying to use the progress bar tool but I am a little lost on how to use it could someone give me some ideas on how to put it together, thanks

    Code:
    Public Class CustomHomePage
        Private Sub CustomHomePage_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
        End Sub
    #Region "go button"
        Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGo.Click
            WebBrowser1.Navigate(cbxWebSearch.Text)
    
        End Sub
    #End Region 'go button complete
    
    #Region "back button"
        Private Sub tsbBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tsbBack.Click
            WebBrowser1.GoBack()
            cbxWebSearch.Text = WebBrowser1.Url.ToString()
    
        End Sub
    #End Region 'back button complete
    
    #Region "forward button"
        Private Sub btnForward_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnForward.Click
            WebBrowser1.GoForward()
            cbxWebSearch.Text = WebBrowser1.Url.ToString()
    
        End Sub
    #End Region 'forward button complete
    
    #Region "Favorites tab"
    
        Private Sub ToolStripButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton3.Click
    
        End Sub
        Private Sub CopyWithProgress(ByVal ParamArray filenames As String())
            ' Display the ProgressBar control.
            PBar1.Visible = True
            ' Set Minimum to 1 to represent the first file being copied.
            PBar1.Minimum = 1
            ' Set Maximum to the total number of files to copy.
            PBar1.Maximum = filenames.Length
            ' Set the initial value of the ProgressBar.
            PBar1.Value = 1
            ' Set the Step property to a value of 1 to represent each file being copied.
            PBar1.Step = 1
    
            ' Loop through all files to copy.
            Dim x As Integer
            For x = 1 To filenames.Length - 1
                ' Copy the file and increment the ProgressBar if successful.
                If CopyFile(filenames(x - 1)) = True Then
                    ' Perform the increment on the ProgressBar.
                    PBar1.PerformStep()
                End If
            Next x
    
        End Sub
    #End Region ' favorites not complete
    
    #Region "Copy file function"
        Function CopyFile(ByVal value As String) As Boolean
    
            If value = True Then
                Return True
            Else
                Return False
            End If
    
        End Function
    #End Region 'function for progress bar still incomplete
    
    End Class

  2. #2
    Join Date
    Jan 2007
    Posts
    112
    I don't believe anything is wrong with the code for your progress bar. The problem is the CopyFile function. For one it doesn't actually copy a file anywhere. Perhaps you hadn't gotten that far and you were just trying to test the progress bar. The reason the progress bar isn't incrementing is because the CopyFile function will always return false. Comparing a string to the boolean True will test if the string literally equals the value 'True'. Try using this code inside your CopyFile function.
    Code:
    Return not String.IsNullOrEmpty(value)
    As long as your passing non null strings the function will return true and your progress bar should increment. However, your function is clearly intended to copy a file and return a value indicating success/failure. Currently your function doesn't serve this purpose.
    Last edited by TwoFaced; 05-26-2007 at 12:38 PM.

Similar Threads

  1. Replies: 4
    Last Post: 01-22-2008, 02:04 PM
  2. Progress bar which doesn't progress
    By a7n9 in forum VB Classic
    Replies: 3
    Last Post: 08-30-2005, 12:34 AM
  3. Replies: 1
    Last Post: 07-18-2002, 10:48 AM
  4. Replies: 0
    Last Post: 07-29-2001, 12:46 PM
  5. Progress bar on COM
    By Jeff Aziz in forum Enterprise
    Replies: 3
    Last Post: 07-27-2000, 02:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center