borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Randomize generate massive user name database?)Next Topic (Combobox) New Topic New Poll Post Reply
AndreaVB Forum : VB General : Percentage in listbox
Poster Message
Nicholas
Level: Big Cheese

Registered: 31-08-2002
Posts: 22

icon Percentage in listbox

Hi. I'm trying to get percentages from 1% to 100% to show in a LISTBOX but what is happening is at .81 to 100 percent, the number is looking like this: 810000001 and so on for .82, .83... Below is the code I am using and need help. How someone can help. Thanks for efforts all. Nick

For intper = 0.01 To 1 Step 0.01
List5.AddItem IIf(intper > 0, Trim(Str(intper)), "" & Trim(Str(intper)))
Next intper

30-05-2007 at 11:45 AM
View Profile Send Email to User Show All Posts | Quote Reply
admin
Level: Administrator


Registered: 04-04-2002
Posts: 530
icon Re: Percentage in listbox

just use this code:

Dim intper As Integer

For intper = 1 To 100
    List5.AddItem Replace(Format(intper / 100, "#.00"), ",", ".")
Next


you had the error because the representation of a decimal number is not always exact due to the floating point binary conversion.

Replace function is used to convert "," in "."

hope this helps

____________________________
AndreaVB

30-05-2007 at 12:39 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
Nicholas
Level: Big Cheese

Registered: 31-08-2002
Posts: 22
icon Re: Percentage in listbox

That worked fine. Thank you for the correct code and reason why it did not work. - Nick

30-05-2007 at 01:42 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VB General : Percentage in listbox
Previous Topic (Randomize generate massive user name database?)Next Topic (Combobox) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder