Results 1 to 10 of 10

Thread: PERCENTAGE in label....

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,941

    PERCENTAGE in label....

    I have myvar=45878 and a loop for next

    during the for next i increase a counter count=count+1

    how to insert in labe the value of percentage based the counter in %

    in effect:

    when count = myvar the percentage is 100%

    hope i am clear

  2. #2
    Hyperactive Member deathfxu's Avatar
    Join Date
    Mar 2009
    Location
    USA
    Posts
    279

    Re: PERCENTAGE in label....

    vb Code:
    1. Label1.Caption = Trim$(CStr(CInt((count / myvar) * 100))) & "%"

    Enjoy!
    Last edited by deathfxu; May 29th, 2009 at 04:21 AM. Reason: added "%" sign :)

  3. #3
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: PERCENTAGE in label....

    Put a Lobel on your form named "NewLabel"
    Code:
    'in you Loop
    NewLabel.Caption=CStr((count/myvar)*100) & "%"
    [edit] Late as usual
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  4. #4
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,969

    Re: PERCENTAGE in label....

    Maybe?

    lblTest.Caption = Int(count * 100 / myvar) & " % Completed"

  5. #5
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,969

    Re: PERCENTAGE in label....

    Man you guys are fast :-)

  6. #6
    Hyperactive Member deathfxu's Avatar
    Join Date
    Mar 2009
    Location
    USA
    Posts
    279

    Re: PERCENTAGE in label....

    Great minds think alike

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,941

    Re: PERCENTAGE in label....

    Quote Originally Posted by deathfxu View Post
    vb Code:
    1. Label1.Caption = Trim$(CStr(CInt((count / myvar) * 100))) & "%"

    Enjoy!
    tks to the all!!!!!

    the babel show the value of increase during the loop....
    only if i insert doevents....
    existis other method?

    I have see the doevets statement slow the loop, or not?

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: PERCENTAGE in label....

    Without the Doevents you wouldn't see anything until it was all over.

  9. #9
    Hyperactive Member deathfxu's Avatar
    Join Date
    Mar 2009
    Location
    USA
    Posts
    279

    Re: PERCENTAGE in label....

    Agree w/ Hack.

    Also, check out the "Improved DoEvents" link in my sig.

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

    Re: PERCENTAGE in label....

    You don't need to use DoEvents (which refreshes all controls, allows events to fire, etc), you can get the same effect by just refreshing the particular control(s) you want, eg:
    Code:
    Label1.Caption = Trim$(CStr(CInt((count / myvar) * 100))) & "%" 
    Label1.Refresh

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