```
' By Joannes Vermorel, 2008-05-04' Copyright (c) 2008, LOKAD SAS
' Returns the probability a call waits.
' m is the agent count
' u is the traffic intensity
Public Function ErlangC(ByVal m As Integer, ByVal u As Double) As Double
d = PowerFact(m, u)
s = 1
For k = 1 To m - 1
s = s + PowerFact(k, u)
Next k
' ErlangC = s
ErlangC = d / (d + (1 - u / m) * s)
End Function
' Return Power(u, k) / Factorial(k) in a numeric-safe manner.
Public Function PowerFact(ByVal m As Integer, ByVal x As Double) As Double
s = 0
For k = 1 To m
s = s + Math.Log(x / k)
Next k
PowerFact = Math.Exp(s)
End Function
' Returns the probability a call waits.
' m is the agent count
' u is the traffic intensity
' tt is the target wait time
' tc is the average call time
Public Function ErlangCsrv(ByVal m As Integer, ByVal u As Double, ByVal tc As Double, ByVal tt As Double) As Double
ErlangCsrv = 1 - ErlangC(m, u) * Math.Exp(-(m - u) * (tt / tc))
End Function
' Returns the average speed of answer (ASA)
' m is the agent counts.
' u is the traffic intensity
' tc is the average call time
Public Function ASA(ByVal m As Integer, ByVal u As Double, ByVal tc As Double) As Double
ASA = ErlangC(m, u) * tc / (m - u)
End Function
```