Results 1 to 8 of 8

Thread: Printer.CurrentX being reset to 0 <RESOLVED>

  1. #1

    Thread Starter
    Addicted Member run_GMoney's Avatar
    Join Date
    May 2002
    Location
    Detroit
    Posts
    186

    Printer.CurrentX being reset to 0 <RESOLVED>

    Can anyone tell me a reason why Printer.CurrentX is being reset during this loop?
    VB Code:
    1. Printer.CurrentX = 1000
    2. Printer.CurrentY = 10800
    3. For i = 13 To 19
    4.     Printer.Print Label8(i).Caption
    5.     Printer.CurrentX = Printer.CurrentX + 900
    6.     Printer.CurrentY = 10800
    7. Next

    If I put a stop up on the first line of the loop (Printer.Print Label8(i).Caption) and query the machine for the value of Printer.CurrentX it returns 1000, like it should. However when I step to the next line (Printer.CurrentX = Printer.CurrentX + 900)and query again, the value has been reset to 0. Anyone know why? It's quite annoying because everything seems correct in my code. Thanks
    Last edited by run_GMoney; Jan 28th, 2003 at 12:03 PM.
    Place Your VBForums Ad Here

  2. #2
    Frenzied Member Blobby's Avatar
    Join Date
    Oct 2001
    Location
    England
    Posts
    1,512
    You must add a semicolon ( ; ) to the end of the Print statement for it to stay on the same line. You will also need to add a space character or 2 after the print or every caption will be butted up to each other.

    VB Code:
    1. Printer.CurrentX = 1000
    2. Printer.CurrentY = 10800
    3. For i = 13 To 19
    4.     Printer.Print Label8(i).Caption & "   ";
    5.     Printer.CurrentX = Printer.CurrentX + 900
    6.     Printer.CurrentY = 10800
    7. Next

    When you want to print something else after the loop finishes you must do a straight Printer.Print (which is like a carriage return) or that too will be on the same line as the stuff printed in the loop
    Last edited by Blobby; Jan 28th, 2003 at 11:43 AM.
    There are 3 types of people in this world.........those that can count, and those that can't.

    Blobby

  3. #3

    Thread Starter
    Addicted Member run_GMoney's Avatar
    Join Date
    May 2002
    Location
    Detroit
    Posts
    186
    Why is it that this bit of code, which appears right before it, works fine.
    VB Code:
    1. Printer.CurrentX = 750
    2. Printer.CurrentY = 3400
    3. For i = 0 To 6
    4.     Printer.Print Label8(i).Caption
    5.     Printer.CurrentX = 700
    6.     Printer.CurrentY = Printer.CurrentY + 985
    7. Next
    Can you not just adjust the CurrentX value to determine where the caption is printed?
    Place Your VBForums Ad Here

  4. #4
    Frenzied Member Blobby's Avatar
    Join Date
    Oct 2001
    Location
    England
    Posts
    1,512
    Because the code that works fine is using CurrentY and NOT Current X.
    There are 3 types of people in this world.........those that can count, and those that can't.

    Blobby

  5. #5

    Thread Starter
    Addicted Member run_GMoney's Avatar
    Join Date
    May 2002
    Location
    Detroit
    Posts
    186
    Ok...right. But what's the difference? Are you saying you can't adjust the value of CurrentX in a loop like you can with CurrentY? That seems silly.
    Place Your VBForums Ad Here

  6. #6
    Frenzied Member Blobby's Avatar
    Join Date
    Oct 2001
    Location
    England
    Posts
    1,512
    Everytime you do a Print, Vb treats it like a carriage ruturn so sets currentX back to the start of the line (0) unless you add a semicolon to the end of the print line, then it DOESNT reset.
    Only other way would be to save CurrentX in a variable before the print then set CurrentX=savevariable after but you would also have to add the textwidth of the printed text to keep up with the current print position
    Last edited by Blobby; Jan 28th, 2003 at 01:10 PM.
    There are 3 types of people in this world.........those that can count, and those that can't.

    Blobby

  7. #7

    Thread Starter
    Addicted Member run_GMoney's Avatar
    Join Date
    May 2002
    Location
    Detroit
    Posts
    186
    Outstanding. I didn't realize that it treated it as a carriage return. I just assumed both would work the same way. Thanks for your patience.
    Place Your VBForums Ad Here

  8. #8
    Frenzied Member Blobby's Avatar
    Join Date
    Oct 2001
    Location
    England
    Posts
    1,512
    No probs m8....thats what this forum is for.
    There are 3 types of people in this world.........those that can count, and those that can't.

    Blobby

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width