Function DcToQt$(x#)
Dim xt$, p%, n&, d&, c%, y&, z1, z2
xt = x
p = InStr(1, xt, ",")
If p = 0 Then
DcToQt = x
Exit Function
End If
If Len(xt) > 9 + p Then
DcToQt = "Non Décimal"
Exit Function
End If
n = Left(xt, p - 1)
c = Len(xt) - p
d = Right(xt, c)
y = (1 & String(c, "0"))
z1 = Smp(d, y, 1)
z2 = Smp(d, y, 2)
DcToQt = (n * z2 + z1) & "/" & z2
End Function
Private Function Smp&(x&, y&, Arg%)
'(1) x/pgcd(x,y),(2) y/pgcd(x,y)
Dim a&, b&, c&
a = x: b = y
Do While a Mod b <> 0
c = a: a = b: b = c Mod b
Loop
Select Case Arg
Case 1
Smp = Int(x / b)
Case 2
Smp = Int(y / b)
End Select
End Function