|
-
Mar 22nd, 2006, 06:56 AM
#1
Thread Starter
Lively Member
-
Mar 22nd, 2006, 09:24 AM
#2
Thread Starter
Lively Member
Re: carriage return problems
looks like what im doing isnt possible or probably just plain stupid!!
can anyone suggest a better way to have this setup so that printing will be easier and
alligned prooperly.
Thanks
-
Mar 22nd, 2006, 09:30 AM
#3
Fanatic Member
Re: carriage return problems
Post the code that you are using to print with. That may help us to better see your problem.
Using VB6 or VB.net 2008 with .net 3.5
"Life... death... either way I'll be confined to a small cubicle!" - Hermes Conrad
-
Mar 22nd, 2006, 09:43 AM
#4
Re: carriage return problems
-
Mar 22nd, 2006, 10:04 AM
#5
Conquistador
Re: carriage return problems
Does it print the contents of Product down the page, followed by Code then unit Price etc ?
If that's the case, I have a fair idea of what your problem is
-
Mar 22nd, 2006, 11:12 AM
#6
Thread Starter
Lively Member
Re: carriage return problems
Yes da_silvy, it prints the Product down the page, then Code gets printed beside the last entry of product, then list of codes gets printed.....
this is the code i am using:
VB Code:
Printer.FontSize = 12
Printer.Print Text1.Text
Printer.Print Label12.Caption
Printer.Print Text3.Text, Text4.Text, Text5.Text, Text6.Text, Text7.Text, Text8.Text
Printer.EndDoc
Jcs i think vbCr is the same as carriage return and will still tell the printer to return to a new line, thanks for your input though.
-
Mar 22nd, 2006, 11:23 AM
#7
Re: carriage return problems
The common way for something like that would be using a listview or a flexgrid, so you can move cell by cell, and print cell by cell at any position you want.
If, for some reason you want to make it this way (using textboxes) and you know all of them will have the same amount of lines (separated by vbNewLine), maybe you could Split 1 of that textboxes into pieces, and use that index to move 1 by 1 printing each position each time, it will be a little hard, as I said it's not the best way to do it.
-
Mar 22nd, 2006, 11:33 AM
#8
Thread Starter
Lively Member
Re: carriage return problems
I dont have to use text boxes, its just that my limited experience dosent extend that far!!! I'll do a search on how to use a flexgrid, thanks
-
Mar 22nd, 2006, 11:37 AM
#9
Re: carriage return problems
-
Mar 22nd, 2006, 11:54 AM
#10
Thread Starter
Lively Member
Re: carriage return problems
cheers, jcis, bit over my head here i think, im about 98% complete on this project so i think ill soldier on with text boxes as time is not on my side!!!! I can do it ok with 1 text box but the spacing isnt the best, thanks for the help!
-
Mar 22nd, 2006, 12:07 PM
#11
Re: carriage return problems
 Originally Posted by paulhenderson
cheers, jcis, bit over my head here i think, im about 98% complete on this project so i think ill soldier on with text boxes as time is not on my side!!!! I can do it ok with 1 text box but the spacing isnt the best, thanks for the help!
Ok, but, if you don't have your answer dont mark the thread resolved, there could be a way to do it with textboxes also, I'll give an example here, maybe someone come up with something even better, try..
VB Code:
Private Sub Command1_Click()
Dim i As Integer
Printer.FontSize = 12
Printer.FontName = "Courier New" 'Fixed length font
For i = 0 To UBound(Split(Text3.Text, vbNewLine))
Printer.Print FillSpaces(Split(Text3.Text, vbNewLine)(i), 20);
Printer.Print FillSpaces(Split(Text4.Text, vbNewLine)(i), 15);
Printer.Print FillSpaces(Split(Text5.Text, vbNewLine)(i), 10);
Printer.Print FillSpaces(Split(Text6.Text, vbNewLine)(i), 8);
Printer.Print FillSpaces(Split(Text7.Text, vbNewLine)(i), 8);
Printer.Print FillSpaces(Split(Text8.Text, vbNewLine)(i), 8)
Next
Printer.EndDoc
End Sub
Private Function FillSpaces(ByVal pStr As String, pCount As Integer) As String
Do While Len(pStr) < pCount
pStr = pStr & " "
Loop
FillSpaces = pStr
End Function
Last edited by jcis; Mar 22nd, 2006 at 12:24 PM.
-
Mar 22nd, 2006, 06:38 PM
#12
Conquistador
Re: [RESOLVED] carriage return problems
For future reference, it's better to name your textboxes and controls something more useful, so you don't need to go back looking at your form to work out what everything is!
I'd also be inclined to split the strings outside of the loop, otherwise they're being split every iteration.
e.g.
dim strProduct() as string, strCode() as string
strProduct = Split(text3.text, vbnewline)
etc..
For i = 0 to Ubound(strProduct)
printer.print fillspaces(strproduct(i), 20)
etc
next
as for the fillspaces function
VB Code:
Private Function FillSpaces(ByVal pStr As String, pCount As Integer) As String
FillSpaces = pStr & Space(pCount - Len(pStr))
End Function
Is what i'd do, but anyway!
Hope it all helps
-
Mar 28th, 2006, 05:35 AM
#13
Thread Starter
Lively Member
Re: [RESOLVED] carriage return problems
Hi guys, really good answers there, really apreciate it, sorry it took so long to reply but was enjoying St Patricks day for while!!!!
Big Thanks!
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
|