Progress bar with percentage

Discussion in 'Visual Basic .NET' started by veco888, Nov 6, 2013.

  1. veco888

    veco888 Newbie

    Joined:
    Oct 29, 2012
    Messages:
    34
    Likes Received:
    5
    How to make a "slow" progress bar showing a percentage instead of just putting " %".
    Progressbar1.Maximum = 800
    ...

    Thanks in advance.
     
  2. Macthetrix

    Macthetrix Regular Member

    Joined:
    Feb 21, 2013
    Messages:
    379
    Likes Received:
    393
    Occupation:
    The Boss
    Location:
    Silicon Valley
    Not sure what language you are using. But you need to set the value.

    ProgressBar.Value = 1;
    ProgressBar.Value++;

    If your program is not multithreaded you can simple use async await to update the Form
     
  3. veco888

    veco888 Newbie

    Joined:
    Oct 29, 2012
    Messages:
    34
    Likes Received:
    5
    I need a fake downloader with progress bar showing percentage in the label. I know how to set it when value = 100, but what to do when I need to set bigger value, how to calculate percentage.

    VB NET
     
  4. Macthetrix

    Macthetrix Regular Member

    Joined:
    Feb 21, 2013
    Messages:
    379
    Likes Received:
    393
    Occupation:
    The Boss
    Location:
    Silicon Valley
    public async void ProgressBar()
    {
    progressBar.Value=0;
    for(i=0;1<100;i++)
    {
    progressBar.Value++;
    textBlock.Text= i.ToString() + " %";
    await Task.Delay(100); // wait 100ms
    }
    }

    This should do the job. Set the delay in ms before adding 1%. Same concept should work for VB.NET
     
  5. cutekid1

    cutekid1 Regular Member

    Joined:
    Sep 30, 2012
    Messages:
    255
    Likes Received:
    75
    add a timer & write code it
    progressbar.value = progressbar.value + 1
    if progressbar.value = 100
    msgbox.show("done")
    end if