Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

??? String to number

0 views
Skip to first unread message

Vsn

unread,
Nov 24, 2009, 4:15:00 PM11/24/09
to
Hi all,

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

Douglas J. Steele

unread,
Nov 24, 2009, 5:26:59 PM11/24/09
to
That's not how Replace works:

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...

Vsn

unread,
Nov 25, 2009, 5:14:22 PM11/25/09
to
That was rather stupid of me, let call it had been a long day.

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...

Raquel de macedo oliveira

unread,
Feb 13, 2010, 11:45:23 AM2/13/10
to
hfhrhjufjjfuidh\nayroBVYnrtgnGrndhy7g,hkthy7mgt7bgh
ABGGGGGG\Zotmail_dot_com> escreveu na mensagem
news:ECAFF6F8-F841-4955...@microsoft.com...

John Spencer

unread,
Feb 13, 2010, 1:46:22 PM2/13/10
to
Try
Varx=Replace (varX, Chr(44), Chr(46))

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

0 new messages