ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   lenght of a number (https://www.excelbanter.com/excel-programming/292500-lenght-number.html)

dreamer[_13_]

lenght of a number
 
Is there something that I should know about function lenght an
numbers?

I have used this in a loop:

[vb]

Left (start, Len(start)-2)

[vb]

with "start" being a number that changes from 5.0 to 110.5. An
Len(start) always returns 8 as lenght of the number??
What am I doing wrong

--
Message posted from http://www.ExcelForum.com


Frank Kabel

lenght of a number
 
Hi
normally I would suggest not to use string operations on numbers. what
are you trying to achieve with this function - there may be better
solutions. But if you want to use Len you may try
Left (CStr(start), Len(CStr(start))-2)

--
Regards
Frank Kabel
Frankfurt, Germany

Is there something that I should know about function lenght and
numbers?

I have used this in a loop:

[vb]

Left (start, Len(start)-2)

[vb]

with "start" being a number that changes from 5.0 to 110.5. And
Len(start) always returns 8 as lenght of the number??
What am I doing wrong?


---
Message posted from http://www.ExcelForum.com/



Bob Phillips[_6_]

lenght of a number
 
Have you declared start as a type Double? If so, you are getting the length
of a double variable, 8 bytes. This only works properly on a string
variable. You could trying casting to string like

Len(CStr(start))

but be aware that 5.0 will return 1, as the value is 5.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"dreamer " wrote in message
...
Is there something that I should know about function lenght and
numbers?

I have used this in a loop:

[vb]

Left (start, Len(start)-2)

[vb]

with "start" being a number that changes from 5.0 to 110.5. And
Len(start) always returns 8 as lenght of the number??
What am I doing wrong?


---
Message posted from http://www.ExcelForum.com/




dreamer[_15_]

lenght of a number
 
Hmm, Cstr also doesn't do what I want.
Is there any other way to do this

--
Message posted from http://www.ExcelForum.com


Frank Kabel

lenght of a number
 
In addition to Bob
Len(Format(start,"0.0"))

would return 3 for the value 5.0


--
Regards
Frank Kabel
Frankfurt, Germany

Bob Phillips wrote:
Have you declared start as a type Double? If so, you are getting the
length of a double variable, 8 bytes. This only works properly on a
string variable. You could trying casting to string like

Len(CStr(start))

but be aware that 5.0 will return 1, as the value is 5.


"dreamer " wrote in message
...
Is there something that I should know about function lenght and
numbers?

I have used this in a loop:

[vb]

Left (start, Len(start)-2)

[vb]

with "start" being a number that changes from 5.0 to 110.5. And
Len(start) always returns 8 as lenght of the number??
What am I doing wrong?


---
Message posted from http://www.ExcelForum.com/


Fatz[_2_]

lenght of a number
 
dreamer < postulated on 2/25/2004 8:03 AM:
Is there something that I should know about function lenght and
numbers?

I have used this in a loop:

[vb]

Left (start, Len(start)-2)

[vb]

with "start" being a number that changes from 5.0 to 110.5. And
Len(start) always returns 8 as lenght of the number??
What am I doing wrong?


---
Message posted from http://www.ExcelForum.com/


To count the number of digits to the left of the decimal point . . .
=INT(LOG10(A3))+1

david fixemer

lenght of a number
 
Dreamer,

Have you got your problem figured out yet?

The way you wrote ".0" makes me think your seing "5.0"
with your eyes? Where are you seeing it? (msgbox,
immediate window, a cell inside Excel)

Sincerely,

David Fixemer




All times are GMT +1. The time now is 11:07 PM.

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