|
-
Jan 28th, 2003, 11:14 AM
#1
Thread Starter
Addicted Member
Printer.CurrentX being reset to 0 <RESOLVED>
Can anyone tell me a reason why Printer.CurrentX is being reset during this loop?
VB Code:
Printer.CurrentX = 1000
Printer.CurrentY = 10800
For i = 13 To 19
Printer.Print Label8(i).Caption
Printer.CurrentX = Printer.CurrentX + 900
Printer.CurrentY = 10800
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
-
Jan 28th, 2003, 11:35 AM
#2
Frenzied Member
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:
Printer.CurrentX = 1000
Printer.CurrentY = 10800
For i = 13 To 19
Printer.Print Label8(i).Caption & " ";
Printer.CurrentX = Printer.CurrentX + 900
Printer.CurrentY = 10800
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
-
Jan 28th, 2003, 11:45 AM
#3
Thread Starter
Addicted Member
Why is it that this bit of code, which appears right before it, works fine.
VB Code:
Printer.CurrentX = 750
Printer.CurrentY = 3400
For i = 0 To 6
Printer.Print Label8(i).Caption
Printer.CurrentX = 700
Printer.CurrentY = Printer.CurrentY + 985
Next
Can you not just adjust the CurrentX value to determine where the caption is printed?
Place Your VBForums Ad Here
-
Jan 28th, 2003, 11:48 AM
#4
Frenzied Member
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
-
Jan 28th, 2003, 11:51 AM
#5
Thread Starter
Addicted Member
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
-
Jan 28th, 2003, 11:56 AM
#6
Frenzied Member
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
-
Jan 28th, 2003, 12:03 PM
#7
Thread Starter
Addicted Member
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
-
Jan 28th, 2003, 01:11 PM
#8
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|