lenght of a number

  • Thread starter Thread starter dreamer
  • Start date Start date
D

dreamer

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
 
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)
 
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)
 
In addition to Bob
Len(Format(start,"0.0"))

would return 3 for the value 5.0


--
Regards
Frank Kabel
Frankfurt, Germany

Bob said:
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 > said:
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?
 
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?

To count the number of digits to the left of the decimal point . . .
=INT(LOG10(A3))+1
 
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
 
Back
Top