title: Excel VBA decimal numbers get converted to integers in text output
body: <p>I have a spreadsheet, and I have written a macro which uses some of the values in the spreadsheet to output a text file. Everything works fine except one issue:</p>
  
  <p>If I have a floating number like 15.0, it shows up in the output text file as integer 15, without the decimal point. I do not observe the same issue if the number after the decimal point is something other than zero, e.g., 15.1 gets written as 15.1; no problem there.</p>
  
  <p>I wonder if there is some kind of a command or property, which would force all numbers are written to the output file as floating numbers?</p>
  
  <p>This is the line I write the numbers to the text file. WeightList(i) and SpacingList(i) are string arrays, which are used for storing the numbers collected from the spreadsheet.</p>
  
  <pre><code>Print #1, Chr(9); "&lt;truck axleW=" &amp; Chr(34) &amp; _
            WeightList(i) &amp; Chr(34) &amp; " axleS=" &amp; _
            Chr(34) &amp; SpacingList(i) &amp; Chr(34) &amp; "&gt;&lt;/truck&gt;"
  </code></pre>
  
  <p>Thank you!</p>
  
  <p>EDIT: This is the line where the numbers are converted to strings, I tried using the format command but this did not help:</p>
  
  <pre><code>WeightList(i) = Format("0.0", Truck(i).AxleWeights(i))
  </code></pre>
  
  <p>EDIT2: The code works now, after changing the order of the arguments in the format command. Please see the accepted answer for details.</p>