Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

printing a number with right justification 1

Status
Not open for further replies.

shanmugham

Programmer
Jun 19, 2001
71
0
0
IN
Dear Sir,

i have a number a = 10
b = 1000
c = 1234567
i want to print the following format
10
1000
1234567
how to do this


printing a numer with right justification

thanks in advance

shan
 
Check out the format statement. And please don't call me "sir", I was never in the military! ;-)

"I think we're all Bozos on this bus!" - Firesign Theatre [jester]
 
i am using
Format(rs("tottax"), "######"))

it dossnot work

thanks in advance
shan
 
No right-justification in the format statement - doh!

Here's one method:

Replace(Format(123, "000000"), "0", " ")

or

right(space(10) + cstr(123),6)


"I think we're all Bozos on this bus!" - Firesign Theatre [jester]
 
Replace(Format(123, "000000"), "0", " "), this statement
it change 1000 as 1
is it right ?

right(space(10) + cstr(123),6) in this statement
i don't know the exact width of the numbers

how to overcome this

thanks in advacne
shan






 
Yes friend, second statement working fine

many thanks
shan
 
The easy way is to use the RSet statement:
[tt]
myBlank = Space$(10)
myNum1 = 123
Rset myBlank = myNum1
MsgBox myBlank
[/tt]

will produce:
[tt]
123
[/tt]

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Format will work:

Open "C:\Test.txt" For Output As #1
Print #1, Format$("10", String$(10, "@"))
Print #1, Format$("1000", String$(10, "@"))
Print #1, Format$("1234567", String$(10, "@"))
Close #1

Swi
 
If you are printing these numbers to the printer object (this will work for a picture box also) you could do this:

Printer.Currentx = X - Printer.TextWidth(Yournumber)

X being the rightmost position where you want your numbers
If you want your numbers formatted put the Format function around "Yournumber":

Printer.Currentx = X - Printer.TextWidth(Format(Yournumber,"##,##0"))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top