[AccessD] Calculate Quartile

Arthur Fuller fuller.artful at gmail.com
Sun Jul 5 04:55:22 CDT 2009


It's a teeny bit more complicated than that, Max, but you set me to
thinking. Here is my little test program and two functions, the first of
which does it call by call and the second does it all in one line, using
nested calls.
<vba>
Option Compare Database
Option Explicit

Sub Test()
    Dim x As String, y As String, z As String
    x = "123.456.789,12"
    Debug.Print x
    y = SwapComma(x)
    Debug.Print y
    z = SwapComma2(x)   'do it all in one call
    Debug.Print z
End Sub

Function SwapComma(x As String)
    x = Replace(x, ",", "%")
    Debug.Print x
    x = Replace(x, ".", ",")
    Debug.Print x
    x = Replace(x, "%", ".")
    Debug.Print x
    SwapComma = x
End Function

Function SwapComma2(x As String)
    ' not for the faint at heart
    SwapComma2 = Replace(Replace(Replace(x, ",", "%"), ".", ","), "%", ".")
End Function
</vba>

Which solves the problem as posed, but makes no attempt to understand the
wisdom behind Microsoft's lack of a universal representation.

hth,
Arthur



More information about the AccessD mailing list