Quantcast
Channel: Xojo Programming Forum - Latest topics
Viewing all articles
Browse latest Browse all 3780

Loop generates non-fatal problem

$
0
0

I’m trying to print labels from my app.

When I do not include a loop to print multiple labels based on the value of qty (an integer), I get a single label printing fine.

When I include a loop to print as many times as my quantity, I get the right number of labels printing, but the application generates a dialog box that says “This application has encountered a non-fatal problem. Report Now/Ignore” and then hangs until I force quit.

I suspect it may have something to do with variables becoming localized to the loop, but I can’t seem to figure out what to move around to make this work. Thoughts? Solution?

// print the label

Var ps As New PrinterSetup
Var g As Graphics
ps.Settings = App.s

If TextField_qty.Text.IsNumeric Then
  Var x as Integer
  Var qty as Integer = TextField_qty.text.ToInteger
  For x = 0 to qty 
    g = PrinterSetup.OpenPrinter(ps)
    g.FontName = "IDAutomationHC39M Free Version"
    g.FontSize = 12
    If g <> Nil Then
      // Print bar code label
      g.DrawText(TextArea_BarCode.text,15,50)
    end if  
  Next
end if

So again to clarify, the code above prints without error if I remove the For/Next statements, but of course only prints a single label.

7 posts - 4 participants

Read full topic


Viewing all articles
Browse latest Browse all 3780

Trending Articles