Using Visual Basic with a Lighthouse printer

18 Views Asked by At

We print labels using Lighthouse CPM-100HG5 printers, and I want to populate one of the variables using Visual Basic code rather than entering data at the printing prompt.

My code is:

weekNum = DatePart("ww", Now())
lastTwoYearDigits = Right(Year(Now()), 2)
orderNumber = InputBox("Enter order number:")
revisionNumber = InputBox("Enter SAP revision number:")
Result = weekNum & lastTwoYearDigits & "G" & Right(orderNumber, 3) & "R" & revisionNumber
WriteLineToFile "J:\Test\Label Output\OrderData\" & orderNumber & ".txt", "TCode:" & Result
MsgBox Result

All it basically does is build up a code used to trace cable assemblies, and write it to a text file to be read by our test equipment for inspection purposes. It works well when I check the code, but rather than just running once at the printing prompt it seems to run repeatedly as soon as the label is loaded.

I've tried using a While loop to check whether "Result" has null value, but this doesn't make any difference. There's obviously some other way I'm supposed to be going about this, perhaps coding it to be triggered by the print prompt in some way, but the documentation regarding this is terrible.

I'm hoping somebody here will have some experience with these printers, as it seems like a reasonably simple problem..

0

There are 0 best solutions below