Printing going well --Aligning decimal points?

S

StrandElectric

Well, once again Thanks heaps Jason! Have been playing with your code and
all is well. Can use it to generate my reports. What a break-through! Thanks
for info on how to include a reference. I never did that in vb6.

I have nutted out changing the measure to millimetres (my preference),
printer dialog and before that how to change the orientation (thank God for
intellisense) but I am stumped on how to decimally align figures. Of
course 'Help' should tell me that but as I've observed before it is quite
useless!

Suppose I have two (currency but I don't wish to show the $ sign) figures
1.2 and 345.56. How do I format them to print with the *decimal points in
line* , *and* also with 1.2 made out to 1.20?

I used to do it in vb6 with

Dim Aligned As String
....
....
Aligned =Format(AnyVariable, "#,###.00"): Printer.CurrentX = 149 -
Printer.TextWidth(Aligned)

This gives me right alignment but it is the *decimals* I want aligned, and
also the 1.2 dollars padded out to 0 in the absence of an explicit 0. Of
course in vb6 this was catered for by the type 'Currency' and of course
vb.net doesn't have it. Another real world omission?
 
N

Nobody

StrandElectric said:
Well, once again Thanks heaps Jason! Have been playing with your code and
all is well. Can use it to generate my reports. What a break-through!
Thanks for info on how to include a reference. I never did that in vb6.

I have nutted out changing the measure to millimetres (my preference),
printer dialog and before that how to change the orientation (thank God
for intellisense) but I am stumped on how to decimally align figures. Of
course 'Help' should tell me that but as I've observed before it is quite
useless!

Suppose I have two (currency but I don't wish to show the $ sign) figures
1.2 and 345.56. How do I format them to print with the *decimal points in
line* , *and* also with 1.2 made out to 1.20?

I used to do it in vb6 with

Dim Aligned As String
...
...
Aligned =Format(AnyVariable, "#,###.00"): Printer.CurrentX = 149 -
Printer.TextWidth(Aligned)

This gives me right alignment but it is the *decimals* I want aligned, and
also the 1.2 dollars padded out to 0 in the absence of an explicit 0. Of
course in vb6 this was catered for by the type 'Currency' and of course
vb.net doesn't have it. Another real world omission?

Several ways:

Dim s As String
Dim d As Double

d = 1.2

' One way
s = Format(d, "#,###0.00")
Console.WriteLine ("'" & s & "'")

' Another way
s = d.ToString("#,###0.00")
Console.WriteLine ("'" & s & "'")

Output:

'1.20'
'1.20'

I can't help you with the second line.
 
A

Armin Zingler

Am 26.01.2011 00:40, schrieb StrandElectric:
I have nutted out changing the measure to millimetres (my preference),
printer dialog and before that how to change the orientation (thank God for
intellisense) but I am stumped on how to decimally align figures. Of
course 'Help' should tell me that but as I've observed before it is quite
useless!

Useless in which respect?
Suppose I have two (currency but I don't wish to show the $ sign) figures
1.2 and 345.56. How do I format them to print with the *decimal points in
line* , *and* also with 1.2 made out to 1.20?

I used to do it in vb6 with

Dim Aligned As String
....
....
Aligned =Format(AnyVariable, "#,###.00"): Printer.CurrentX = 149 -
Printer.TextWidth(Aligned)

This gives me right alignment but it is the *decimals* I want aligned, and
also the 1.2 dollars padded out to 0 in the absence of an explicit 0.

As you are using Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6.Printer,
you can do it like in VB6: The Printer object has also a CurrentX property
and a TextWidth function. The Format function is also still available.

Be aware that, if you want the decimal point in line _and_ the right border
of the column in line, the two digits must have the same size, i.e. you
must use a fixed width font like "Courier New".
Of
course in vb6 this was catered for by the type 'Currency' and of course
vb.net doesn't have it. Another real world omission?

Of course there is the 'Decimal' type now that is (namely) not limited to
dealing with currency values and 4 decimal places as the Currency type was.
 
J

Jason Keats

StrandElectric said:
Well, once again Thanks heaps Jason! Have been playing with your code and
all is well. Can use it to generate my reports. What a break-through! Thanks
for info on how to include a reference. I never did that in vb6.

I explained how to add a reference on 1st January. I hope you're not
referring to that post! ;-)

Anyway, I'm glad you got the print code working - even though it's only
a slightly simpler version of the code I supplied on the 5th of January.

Happy Australia Day.
 
C

Cor

Strand,

You are so much focusing on VB6, be aware that twips were a one time version
invention, which is completely removed again in version 7.
Just before you go in that trap.

All Net program languages are pixel oriented. Where of course the dpi and
screen resolution influences the way everything which is showed (because
everything is graphical in this 3D decennium)

Cor

"StrandElectric" wrote in message
Well, once again Thanks heaps Jason! Have been playing with your code and
all is well. Can use it to generate my reports. What a break-through! Thanks
for info on how to include a reference. I never did that in vb6.

I have nutted out changing the measure to millimetres (my preference),
printer dialog and before that how to change the orientation (thank God for
intellisense) but I am stumped on how to decimally align figures. Of
course 'Help' should tell me that but as I've observed before it is quite
useless!

Suppose I have two (currency but I don't wish to show the $ sign) figures
1.2 and 345.56. How do I format them to print with the *decimal points in
line* , *and* also with 1.2 made out to 1.20?

I used to do it in vb6 with

Dim Aligned As String
....
....
Aligned =Format(AnyVariable, "#,###.00"): Printer.CurrentX = 149 -
Printer.TextWidth(Aligned)

This gives me right alignment but it is the *decimals* I want aligned, and
also the 1.2 dollars padded out to 0 in the absence of an explicit 0. Of
course in vb6 this was catered for by the type 'Currency' and of course
vb.net doesn't have it. Another real world omission?
 
S

StrandElectric

Armin Zingler said:
Am 26.01.2011 00:40, schrieb StrandElectric:

Useless in which respect?

*** I'm amazed you query that comment!. I thought you agreed with that
anyway... Useless because topic after topic in the index results in an
announcement 'no hep avaialable for this topic".
As you are using
Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6.Printer,
you can do it like in VB6: The Printer object has also a CurrentX property
and a TextWidth function. The Format function is also still available.

Be aware that, if you want the decimal point in line _and_ the right
border
of the column in line, the two digits must have the same size, i.e. you
must use a fixed width font like "Courier New".


Of course there is the 'Decimal' type now that is (namely) not limited to
dealing with currency values and 4 decimal places as the Currency type
was.

***Yes, the need for a fixed width font seems logical, but the fact is that
I did NOT need it in my original vb6 application, all the reports in which
were in Arial!
 
S

StrandElectric

No, I am focussing on a simple business requirement, which is aligning
columns on a report by millimetres. It works! Tha is not the problem.
 
S

StrandElectric

Armin Zingler said:
Am 26.01.2011 00:40, schrieb StrandElectric:

Useless in which respect?


As you are using
Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6.Printer,
you can do it like in VB6: The Printer object has also a CurrentX property
and a TextWidth function. The Format function is also still available.

Be aware that, if you want the decimal point in line

***A real world business application MUST have the *decimals* in line! And
BTW, cannot be formatted eg 1.2 when what is meant is 1.20 (decimal type
does that)

_and_ the right border
 
A

Armin Zingler

Am 26.01.2011 11:23, schrieb StrandElectric:
*** I'm amazed you query that comment!. I thought you agreed with that
anyway... Useless because topic after topic in the index results in an
announcement 'no hep avaialable for this topic".

Still I think there must be something wrong with the installation because
I don't remember having this problem that often. I thought you can
be more specific giving me an example.
***Yes, the need for a fixed width font seems logical, but the fact is that
I did NOT need it in my original vb6 application, all the reports in which
were in Arial!

Uhm, if you have a Font where "0" and "1" are of different width, the Strings
"7.00" and "7.11" can _impossibly_ have the same width. So, if you put
the "." in a line, the right border of the numbers are not in line. And if
you put the right border in line, the "." are not in line.
 
A

Armin Zingler

Am 26.01.2011 11:55, schrieb StrandElectric:
***A real world business application MUST have the *decimals* in line!

Sure. I agree. But my point was:

http://www.abload.de/image.php?img=decimalpointsrmjt.png
http://www.abload.de/image.php?img=decimalpoints2smix.png

I simulated it with two Textboxes and the difference is barely visible,
yet it's true:

On the first picture you see right-aligned columns without the decimal
point in line.

On the second picture you see the decimal point in line but as the two
digits following the "." don't have the same size, the columns are not
_correctly_ right-aligned.

I've used Arial BTW.
 
S

StrandElectric

Armin Zingler said:
Am 26.01.2011 11:55, schrieb StrandElectric:

Sure. I agree. But my point was:

http://www.abload.de/image.php?img=decimalpointsrmjt.png
http://www.abload.de/image.php?img=decimalpoints2smix.png

I simulated it with two Textboxes and the difference is barely visible,
yet it's true:

On the first picture you see right-aligned columns without the decimal
point in line.

On the second picture you see the decimal point in line but as the two
digits following the "." don't have the same size, the columns are not
_correctly_ right-aligned.

I've used Arial BTW.

Fine Armin! Since that's the worst case, '0' against '1', it is perfectly
OK for the right to be slightly out as long as the decimal is correct.
 
A

Armin Zingler

Am 26.01.2011 20:22, schrieb StrandElectric:
Fine Armin! Since that's the worst case, '0' against '1', it is perfectly
OK for the right to be slightly out as long as the decimal is correct.

Ok.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top