|
-
Nov 15th, 2005, 08:52 AM
#1
Thread Starter
Junior Member
Right justify
Is there a way to right justify the output to a printer. For example, I have an order printing out with the itemized amounts left justified so it looks like this:
Results:
900.00
45.00
1.99
I want these results justified to the right so that the decimal point is aligned:
900.00
45.00
1.99 I use the printer.print method to print to the printer. How can this be done?
-
Nov 15th, 2005, 08:55 AM
#2
Fanatic Member
Re: Right justify
You can do...
VB Code:
dim strJustify as string
strJustify = space(10)
Rset strJustify = "900.00"
I do this alot with reports that i need to format.
HTH
Using VB6 or VB.net 2008 with .net 3.5
"Life... death... either way I'll be confined to a small cubicle!" - Hermes Conrad
-
Nov 15th, 2005, 09:10 AM
#3
Thread Starter
Junior Member
Re: Right justify
Thanks for your fast reply Space Monkey, but how do I use Rset in this code:
VB Code:
printer.print rstPBHnd.fields("Results")
I have a couple of records that I want to be printed in a column with the decimal point aligned. I have tried to use Format but that didn't work either.
-
Nov 15th, 2005, 09:19 AM
#4
Fanatic Member
Re: Right justify
Is there a reason you can't do this?
VB Code:
dim strJustify as string
strJustify = space(10)
'.........
Rset strJustify = rstPBHnd.fields("Results")
Printer.Print strJustify
Using VB6 or VB.net 2008 with .net 3.5
"Life... death... either way I'll be confined to a small cubicle!" - Hermes Conrad
-
Nov 15th, 2005, 09:48 AM
#5
Thread Starter
Junior Member
Re: Right justify
Yes, I figured that out eventually. Rset works, but only if the amount of characters is the same.
If I have a result of 9.8 and another of 10.2 then the decimal points will not be aligned. Do I have to check the length of each record and adjust the amount of space acordingly before printing, or is there an faster way ?
-
Nov 15th, 2005, 09:59 AM
#6
Re: Right justify
Is this ok?
VB Code:
Private Sub Form_Load()
Debug.Print RAlign(9.8)
Debug.Print RAlign(10.2)
Debug.Print RAlign(900)
Debug.Print RAlign(45)
Debug.Print RAlign(1.99)
End Sub
Private Function RAlign(pValue As Single) As String
RAlign = Right$(Space(10) & Format(pValue, "0.0"), 10)
End Function
This world is not my home. I'm just passing through.
-
Nov 15th, 2005, 10:07 AM
#7
Re: Right justify
 Originally Posted by trisuglow
Is this ok?
VB Code:
Private Sub Form_Load()
Debug.Print RAlign(9.8)
Debug.Print RAlign(10.2)
Debug.Print RAlign(900)
Debug.Print RAlign(45)
Debug.Print RAlign(1.99)
End Sub
Private Function RAlign(pValue As Single) As String
RAlign = Right$(Space(10) & Format(pValue, "0.0"), 10)
End Function
Slick!
-
Nov 15th, 2005, 10:07 AM
#8
Fanatic Member
Re: Right justify
The other thing you could do would be.
VB Code:
dim strJustify as string
strJustify = space(10)
'.........
Rset strJustify = Format(rstPBHnd.fields("Results"), "0.00")
Printer.Print strJustify
that would force it to have two decimals
Using VB6 or VB.net 2008 with .net 3.5
"Life... death... either way I'll be confined to a small cubicle!" - Hermes Conrad
-
Nov 15th, 2005, 10:36 AM
#9
Thread Starter
Junior Member
Re: Right justify
Thanks for your reply, I will need to do some finetuning for the different amount of chars. I will look into that tomorrow.
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
|