[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Alignment and Numaric Format when printing

Posted on 2002-06-23
5
Medium Priority
?
262 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 800 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

656 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