Attribute VB_Name = "Module1"
Option Explicit

Public Function morethan(tnum1 As String, tnum2 As String) As Boolean
Dim i As Long
Dim dot1 As Long
Dim dot2 As Long
      
      'Find the position of the decimal point (if not present, assume it is 'after' the string)
  dot1 = InStr(tnum1, ".")
  If dot1 = 0 Then dot1 = Len(tnum1) + 1
  dot2 = InStr(tnum2, ".")
  If dot2 = 0 Then dot2 = Len(tnum2) + 1

      'If the decimal points (or lack of!) are in different places, see which comes later (thus the number is bigger)
  If (dot1 <> dot2) Then
    morethan = (dot1 > dot2)
      'the line above is a shorter (and faster) version of this:
      'If (dot1 > dot2) Then
      '  morethan = True
      'Else
      '  morethan = False
      'End If

      'If the strings are the same length, do a simple string comparison (much faster)
  ElseIf Len(tnum1) = Len(tnum2) Then   '(need to be the same length, as not only is "123.1" > "123", but so is "123.0"!)
    morethan = (tnum1 > tnum2)

      'Can't use a short-cut, so check each digit
  Else
        '..up to the decimal point
    For i = 1 To dot1 - 1 '(already know that dot1 = dot2)
        '(there should only be numbers here, so use the faster CInt rather than Val)
      Select Case CInt(Mid$(tnum1, i, 1)) - CInt(Mid$(tnum2, i, 1))
      Case Is > 0
        morethan = True
        Exit Function
      Case Is < 0
        morethan = False
        Exit Function
      End Select
    Next i

        '..after the decimal point, up to the end of the shortest string
    For i = dot1 + 1 To IIf(Len(tnum1) < Len(tnum2), Len(tnum1), Len(tnum2))
      Select Case CInt(Mid$(tnum1, i, 1)) - CInt(Mid$(tnum2, i, 1))
      Case Is > 0
        morethan = True
        Exit Function
      Case Is < 0
        morethan = False
        Exit Function
      End Select
    Next i

        '..check the remainder of the last string (to see if any digit >0)
    If Len(tnum1) < Len(tnum2) Then
      '(dont need to check the rest of num2 - we know num1 is <= , so not MoreThan)
    Else
      For i = Len(tnum2) + 2 To Len(tnum1)
        If CInt(Mid$(tnum1, i, 1)) <> 0 Then  '( <> is faster than > )
          morethan = True
          Exit Function
        End If
      Next i
    End If
        '..they have an equal value
    morethan = False
  End If

End Function
