1 Reply Latest reply on Feb 15, 2017 10:46 AM by Keith Rice

    Output all digits of a double in VBA macro

    Jana Stahn

      I am trying to check values of dimensions with a VBA macro.

      I already have a Dimension object (let's call it "d") and I can output the value via


      Debug.Print d.Value


      but this only outputs the first 15 digits. How can I output all 17 digits?


      MSDN says (here Double.ToString Method (String) (System)  ) that there exists a method to do this:




      But if I write in the macro the following lines


      Dim val As Double

      val = d.Value

      Dim str as String

      str = val.ToString("G17")



      then I get an error that the method (ToString) is not known.


      I am using SolidWorks2016.

        • Re: Output all digits of a double in VBA macro
          Keith Rice

          The MSDN article you linked to is for .NET, not VBA. (Note where it says ".NET Framework" under the main heading.) You would need to recreate the macro as a .NET program in order to use that method. That method does not exist in VBA, hence it is not known.


          Honestly, I am curious why you are wanting to test a dimension out to that many digits since there is no realistic way to even machine something with that amount of precision, assuming we are talking about normal units of measure.



          SolidWorks API Training and Services