ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Trailing Zeros (https://www.excelbanter.com/excel-discussion-misc-queries/205302-trailing-zeros.html)

aftamath77

Trailing Zeros
 
I'm designing a combobox with decimal numbers. When I use .additem and type
in the numbers, it drops the trailing zeros. (ie. 0.500 becomes 0.5
automatically) I need the zeros for precision and consistancy purposes. Is
there a line I can include in this code?

With ComboBox1
.ListRows = 20
.AddItem (0.375)
.AddItem (0.5)
.AddItem (0.75)
End With

Dave Peterson

Trailing Zeros
 
Since they're text in the combobox, just add them as text:

With ComboBox1
.ListRows = 20
.AddItem "0.375"
.AddItem "0.500"
'or even
.AddItem format(0.75,"0.000")
End With

aftamath77 wrote:

I'm designing a combobox with decimal numbers. When I use .additem and type
in the numbers, it drops the trailing zeros. (ie. 0.500 becomes 0.5
automatically) I need the zeros for precision and consistancy purposes. Is
there a line I can include in this code?

With ComboBox1
.ListRows = 20
.AddItem (0.375)
.AddItem (0.5)
.AddItem (0.75)
End With


--

Dave Peterson

Jim Thomlinson

Trailing Zeros
 
..AddItem format(0.375, "0.000")

--
HTH...

Jim Thomlinson


"aftamath77" wrote:

I'm designing a combobox with decimal numbers. When I use .additem and type
in the numbers, it drops the trailing zeros. (ie. 0.500 becomes 0.5
automatically) I need the zeros for precision and consistancy purposes. Is
there a line I can include in this code?

With ComboBox1
.ListRows = 20
.AddItem (0.375)
.AddItem (0.5)
.AddItem (0.75)
End With


aftamath77

Trailing Zeros
 
Thanks Dave. "The simplest answers..."

"Dave Peterson" wrote:

Since they're text in the combobox, just add them as text:

With ComboBox1
.ListRows = 20
.AddItem "0.375"
.AddItem "0.500"
'or even
.AddItem format(0.75,"0.000")
End With

aftamath77 wrote:

I'm designing a combobox with decimal numbers. When I use .additem and type
in the numbers, it drops the trailing zeros. (ie. 0.500 becomes 0.5
automatically) I need the zeros for precision and consistancy purposes. Is
there a line I can include in this code?

With ComboBox1
.ListRows = 20
.AddItem (0.375)
.AddItem (0.5)
.AddItem (0.75)
End With


--

Dave Peterson



All times are GMT +1. The time now is 10:57 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com