2 Replies Latest reply on Feb 1, 2018 4:40 PM by John Boire

    Solidworks API: Integer not an Integer?

    John Boire

      So here is something interesting,
      I wrote a quick function to split a number up, nothing fancy:

       

      Function GetDocNumbers(ConfigNum As Integer) As Variant()

          If ConfigNum > 48 Then

              GetDocNumbers = Array(0, 0, 0)

          End If

      Dim tens, remainder, split, i As Integer

      tens = ConfigNum / 10

      remainder = ConfigNum Mod 10

          If remainder > 0 Then

              split = remainder / tens

              i = remainder Mod tens

          End If

      'Return in an array (Number of Documents, Number of sheets per Document, Leftovers(for uneven numbers)

          If tens = 1 And remainder <= 4 Then

              GetDocNumbers = Array(1, ConfigNum, 0)

          ElseIf tens = 1 And remainder > 4 Then

              GetDocNumbers = Array(2, ConfigNum / 2, i)

          Else

              GetDocNumbers = Array(tens, 10 + split, i)

          End If

         

      Debug.Print ("GetDocNumbers Run: Success")

      End Function

       

      The function runs, however when I put in 22, expecting to get the result
      (2,11,0)
      I get (2.2, 10.909ect, 0)


      Any idea why?
      Is there another data type I need to use? Do I not know what an integer is?