If it is for internal use of your company (for example, to facilitate the warehousing of goods), it is recommended to use CODE 128, which is not limited by the bar code length and can basically input all the characters of the keyboard.
If it is a supermarket barcode, use EAN series barcode.
As for how to print these barcodes with barcode machine, it depends on what printing software you use. Different software editing methods are slightly different.