• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 269
  • Last Modified:

Alignment and Numaric Format when printing

Hi experts

I have problem when printing in VB. I can not format the currancy data with two default decimal place like

1,230.00   this .00 is not coming
2,000.50   this are coming automatically.

At thesame time i also want make right allingment of all the currency records.

Thank u
Sumanta
India



0
sumantachandra
Asked:
sumantachandra
  • 3
1 Solution
 
egsemsemCommented:
If u mean you can't format the number, then use this:
MsgBox Format(number, "###,###.00")

If you mean you can't print the formatted number, then I suggest you change the number after formating it to a string by using str(number), and print the string.

>At thesame time i also want make right allingment of all the currency records.

Could u explain it in more details ?

thank u,
Osama

0
 
Anthony PerkinsCommented:
In addition to egsemsem's comment, to get the numbers to right align in a text format such as NotePad use the following:

Const NUM_MASK = "###,##0.00"
Dim Str_Mask As String

Str_Mask = String(Len(NUM_MASK), "@")
Debug.Print Format$(Format$(1.23, MASK), StrMask)
Debug.Print Format$(Format$(12.34, MASK), StrMask)
Debug.Print Format$(Format$(123.45, MASK), StrMask)
Debug.Print Format$(Format$(1234.56, MASK), StrMask)

Anthony
0
 
Anthony PerkinsCommented:
Sorry, but here is the corrected version:

Const NUM_MASK = "###,##0.00"
Dim Str_Mask As String

Str_Mask = String(Len(NUM_MASK), "@")
Debug.Print Format$(Format$(1.23, NUM_MASK), Str_Mask)
Debug.Print Format$(Format$(12.34, NUM_MASK), Str_Mask)
Debug.Print Format$(Format$(123.45, NUM_MASK), Str_Mask)
Debug.Print Format$(Format$(1234.56, NUM_MASK), Str_Mask)

Anthony
0
 
sumantachandraAuthor Commented:
hi experts.

i'm heighly oblized to all of u for the effort. but i'm still confused. i think i should brife my problem in perticular.

i have a sales table and i want bill / invoice printing.
my db connections are ok. but perticularly i cannot geting desire result when printing currancy filed like as follows

Item           Rate             qty            Total
--------------------------------------------------------
LUX            120               2              240
MUX            100.50            3              301.50
KUX            30                3              90

i want these rate and total column should be right alligned, these 120 or 30 must be coming like 120.00 , 30.00.

i am using hard way printing useing printer.print methode for printing.

I hope u can understand what exactly i want.

Expecting u'r valuable ans.

Sumanta
India


 
0
 
Anthony PerkinsCommented:
Two separate issues:
In order to get decimals use something like:
Printer.Print Format$(120, "###,##0.00")

In addition, if you want to right align use something like:
Printer.Print Format$(Format$(120, "###,##0.00"), "@@@@@@@@@@")

This last is assuming a non-proportional font such as courier, for proportional fonts, it is less trivial.

Anthony
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now