Results 1 to 7 of 7

Thread: Progress Bar

  1. #1

    Thread Starter
    Frenzied Member CoachBarker's Avatar
    Join Date
    Aug 2007
    Location
    Central NY State
    Posts
    1,121

    Progress Bar

    I am trying to use the example provided by jmcilhinney using the BGW and Progress bar, but haven't gotten anywhere. I want the progress bar to actually show the progress of a file loading into an application. I can get the size of the file by using this;

    vb Code:
    1. Dim fileSize As Long
    2. fileSize = FileLen(selectedDatabase)
    3. MessageBox.Show(CStr(fileSize))

    but then have no idea what to do with it.
    Thanks
    CoachBarker

    Code Bank Contribution
    Login/Manage Users/Navigate Records
    VB.Net | C#

    Helpful Links: VB.net Tutorial | C Sharp Tutorial | SQL Basics

  2. #2

  3. #3
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: Progress Bar

    Hi,

    Here's a link how to set a progressbar and the filesize:

    http://msdn.microsoft.com/en-us/library/t9fzsyec.aspx

    Wkr,

    sparrow1
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Progress Bar

    Just note that the Maximum property is type Integer while a file length is type Long. You can simply convert a Long to an Integer but you need to be sure that the value is not too large or it will fail. If there's a chance of that then you are probably better to just use 100 as the Maximum and calculate the progess as a percentage before setting the Value.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Frenzied Member CoachBarker's Avatar
    Join Date
    Aug 2007
    Location
    Central NY State
    Posts
    1,121

    Re: Progress Bar

    Since the running of the rest of the application is dependent on the loading of the database, do I even need to run the progress bar in a BGW? I am running the progress bar like this:

    vb Code:
    1. Me.ProgressBar1.Minimum = 0
    2. Me.ProgressBar1.Maximum = CInt(fileSize)
    3. Me.ProgressBar1.Value = 0
    4. While ProgressBar1.Value < fileSize
    5.      Me.ProgressBar1.Value += 2
    6. End While

    Then displaying the label that states that the database is fully loaded.

    EDIT
    No I guess that won't work right, it takes longer for the database to load. I will try to get it to work in the BGW. And try to use the percentage as jmcilhinney suggetsed.
    Last edited by CoachBarker; Jun 7th, 2008 at 08:19 AM.
    Thanks
    CoachBarker

    Code Bank Contribution
    Login/Manage Users/Navigate Records
    VB.Net | C#

    Helpful Links: VB.net Tutorial | C Sharp Tutorial | SQL Basics

  6. #6

    Thread Starter
    Frenzied Member CoachBarker's Avatar
    Join Date
    Aug 2007
    Location
    Central NY State
    Posts
    1,121

    Re: Progress Bar

    Been working at this off and on all day. To get the percentage I need to use (amountLoaded/ totalSize* 100). I have not been able to figure out how to get the amountLoaded.
    Thanks
    CoachBarker

    Code Bank Contribution
    Login/Manage Users/Navigate Records
    VB.Net | C#

    Helpful Links: VB.net Tutorial | C Sharp Tutorial | SQL Basics

  7. #7

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