|
-
May 29th, 2009, 04:17 AM
#1
Thread Starter
PowerPoster
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
-
May 29th, 2009, 04:20 AM
#2
Hyperactive Member
Re: PERCENTAGE in label....
vb Code:
Label1.Caption = Trim$(CStr(CInt((count / myvar) * 100))) & "%"
Enjoy!
Last edited by deathfxu; May 29th, 2009 at 04:21 AM.
Reason: added "%" sign :)
-
May 29th, 2009, 04:20 AM
#3
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!
-
May 29th, 2009, 04:23 AM
#4
Re: PERCENTAGE in label....
Maybe?
lblTest.Caption = Int(count * 100 / myvar) & " % Completed"
-
May 29th, 2009, 04:23 AM
#5
Re: PERCENTAGE in label....
Man you guys are fast :-)
-
May 29th, 2009, 04:24 AM
#6
Hyperactive Member
Re: PERCENTAGE in label....
Great minds think alike
-
May 29th, 2009, 04:38 AM
#7
Thread Starter
PowerPoster
Re: PERCENTAGE in label....
 Originally Posted by deathfxu
vb Code:
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?
-
May 29th, 2009, 06:18 AM
#8
Re: PERCENTAGE in label....
Without the Doevents you wouldn't see anything until it was all over.
-
May 29th, 2009, 06:33 AM
#9
Hyperactive Member
Re: PERCENTAGE in label....
Agree w/ Hack.
Also, check out the "Improved DoEvents" link in my sig.
-
May 29th, 2009, 09:41 AM
#10
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|