I turn nuts on this one:-
Public Function TurnInToValue(varX As String) As Double
Replace varX, Chr(44), Chr(46)
TurnInToValue = Val(varX)
End Function
Why does ? TurnInToValue("3,6") returns 3 instead of the expected 3.6 (three
point six)?
I would expect the comma in the string to be replaced by a dot and that the
string than would have a value 3.6 (my computer uses a dot as the digital
symbol).
I have a field, representing a number, that is exported from Exact Globe to
Excel as a string value. Than I read the Excel file with an Access
application which needs to work with the value as a number. I thought to
have solved it with above function be nothing like that!
I work here with W7 (excellent) and Office 2007.
Thx,
Ludovic
Public Function TurnInToValue(varX As String) As Double
Dim strTemp As String
strTemp = Replace(varX, Chr(44), Chr(46))
TurnInToValue = Val(varX)
End Function
or (more elegant)
Public Function TurnInToValue(varX As String) As Double
TurnInToValue = Val(Replace(varX, Chr(44), Chr(46)))
End Function
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)
"Vsn" <vsn_at_hotmail_dot_com> wrote in message
news:ECAFF6F8-F841-4955...@microsoft.com...
Thanks for the help, I now go on with a fresh mind.
Ludovic
"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_gmail.com> wrote in message
news:ufkB#UVbKH...@TK2MSFTNGP06.phx.gbl...
or as an all in one operation
TurnInToValue = Val(Replace (varX, Chr(44), Chr(46)))
John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County