Re: Parsing a string format
- From: "Rick Rothstein" <rickNOSPAMnews@xxxxxxxxxxxxxxxxx>
- Date: Fri, 9 Jun 2006 11:37:21 -0400
Oops, I overcomplicated things a bit there, just use the Val command
Val("+5.15109444E-001") = 0.515109444
Val("+5.34925965E+000") = 5.34925965
Val("+4.87351543E+001") = 48.7351543
Then use Round to limit the number of decimal places. eg:
Round(Val("+4.87351543E+001"), 2)
= 48.74
Personally, I think CDbl would be better to use than Val.
No, if it is a US or UK device working in a machine set with a French
Locale then it will not work at all
If I understand your objection correctly, then I should clarify my response
a little. I assumed that Dave suggested Val because it works with the
numbers that the OP posted. Those numbers, of course, where generated in a
locale where the dot is used for the decimal point. In this case, either Val
or CDbl would work. However, if the numbers are being generated in a locale
where the comma is used as the decimal point, then Val would not work as
Dave had intended (the comma would be the first non-numeric character and
Val would stop at it) because the Val function in not regionally aware; but
CDbl, being regionally aware, would work. If someone from another country is
generating the numbers (comma for the decimal point), the use of CDbl would
need to be used. This international numeric stuff is always a pain to work
with because you have to know if the numbers are generated and processed
within the same regionally set-up computer; otherwise mismatch situations
like you suggest can result.
Rick
.
- Follow-Ups:
- Re: Parsing a string format
- From: J French
- Re: Parsing a string format
- References:
- Parsing a string format
- From: ccarson
- Re: Parsing a string format
- From: Dave
- Re: Parsing a string format
- From: Dave
- Re: Parsing a string format
- From: Rick Rothstein
- Re: Parsing a string format
- From: J French
- Parsing a string format
- Prev by Date: Re: Parsing a string format
- Next by Date: Re: Parsing a string format
- Previous by thread: Re: Parsing a string format
- Next by thread: Re: Parsing a string format
- Index(es):
Relevant Pages
|