E.g.
vbn.et Code:
  1. Private Function GetFormatSpecifier(increment As Double) As String
  2.     Dim formatSpecifier As String
  3.     Dim text = increment.ToString()
  4.  
  5.     If text.Contains(".") Then
  6.         Dim fraction = text.Substring(text.IndexOf(".") + 1)
  7.  
  8.         formatSpecifier = "n" & fraction.Length
  9.     Else
  10.         formatSpecifier = "n0"
  11.     End If
  12.  
  13.     Return formatSpecifier
  14. End Function
That's untested but I believe it should do the job. You can test and adjust if required.