Solved

Alignment and Numaric Format when printing

Posted on 2002-06-23
5
252 Views
Last Modified: 2010-05-02
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
Comment
Question by:sumantachandra
  • 3
5 Comments
 
LVL 2

Expert Comment

by:egsemsem
ID: 7101555
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
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 7102348
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
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 7102352
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
 

Author Comment

by:sumantachandra
ID: 7104547
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
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 200 total points
ID: 7104671
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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now