Controlling the length of a number (1 Viewer)

alktrigger

Aimless Extraordinaire
Local time
Today, 06:54
Joined
Jun 9, 2009
Messages
124
I am creating a percent line in my code in an effort to summarize data in a report. I'm quite rusty on my VB, and I just can't remember how to limit the length of numbers

my code is as follows:

Code:
lblPerct.Caption = Str((lblSending.Caption / lblTotal.Caption) * 100) & "%"

the code works flawlessly minus the fact that it outputs to 13 decimal places. What is the command to limit length to one decimal?
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 03:54
Joined
Aug 30, 2003
Messages
36,140
The Round() function would be one way.
 

alktrigger

Aimless Extraordinaire
Local time
Today, 06:54
Joined
Jun 9, 2009
Messages
124
solved it via Format() command. Thanks for the suggestion.

Here is my final code. Using the "%" sign eliminated the need for the " * 100" portion of my original code.

Code:
lblPerct.Caption = Format(Str((lblSending.Caption / lblTotal.Caption)), "#00%")
 

Users who are viewing this thread

Top Bottom