Decimal formatting for output to text file

jcrook

New Member
Joined
Jun 12, 2020
Messages
15
Office Version
  1. 2016
Platform
  1. Windows
Good Afternoon,
I am taking input from excel data and manipulating the values to generate CNC program code for metal cutting CNC machines. I'm sure there are many things wrong with this macro. But, I need to output a numbers to a ".txt" file that has at least a decimal point. The values that are currently "doubles" are output with a decimal. The values that are entered into the spreadsheet as decimals, ex: 1.0 or 3.0, endup as integers upon output to the text file. This is a no-no for a cnc control because a coordinate like X4 is actually read as X0.0004 because the industry standard is 4 places to the right of the decimal point if none is input. Where X1. = X1., again X3 = X0.0003. This is tenths of thousands in inch.
I've a screen shot of the spreadsheet, the text output, and some screen shots of the macro code where I'm printing to the text file. I'm not using "Write" because it includes the "" marks, these are not understood by the control.
I need to output everything as a decimal number(double). I would like all values to have at least 1 zero to the right of the dec pt, X1 = X1.0.
Thanks in Advance,
Jay.
 

Attachments

  • Rect Pckt Screen Shot.PNG
    Rect Pckt Screen Shot.PNG
    83.6 KB · Views: 42
  • cnc text file.PNG
    cnc text file.PNG
    29.7 KB · Views: 44
  • rect macro code1.PNG
    rect macro code1.PNG
    44.3 KB · Views: 39
  • rect macro code2.PNG
    rect macro code2.PNG
    49.2 KB · Views: 35
delighted to have helped. Another thought would be to do all the calculations in Excel rather than VBA - you would be able to see all the results before printing and could structure a page with all the output cells in the right order for checking before simply saving that region as a text file. Possibly no need for VBA at all.

All the best.
 
Upvote 0

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Hi Peter,
Thanks Again for our help.
I have another worksheet in the same workbook similar to your last reply.
I'll look at outputting that region to a text file.

Thanks Again,
Jay.
 
Upvote 0

Forum statistics

Threads
1,223,098
Messages
6,170,100
Members
452,301
Latest member
QualityAssurance

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top