Printing Text - Content Alignment

Hi everyone,

I will appreciate if someone can help me with an idea to solve this issue. I need to print the content of several editfields that contain numbers. The print is generated without problem but all the numbers are aligned to the left:

15,000
7,000
11,000

Is there some way to print all the numbers aligned to the right…?

15,000
7,000
11,000

`

Dim p as Graphics

//Vars
p=OpenPrinterDialog()

If p<>Nil Then

p.DrawString (“15,000”,50,50)
p.DrawString (“7,000”,50,60)
p.DrawString (“11,000”,50,70)

End If

`

Thanks in advance.

mynumber = format(1234.56, "###,###.00") p.drawstring(mynumber, (p.width-p.stringwidth(mynumber))-marginright, 100)

Hi Michel,

Really thanks ! works great.

Taking your example code, it would be something like this:

`

Dim p as Graphics
Dim mynumber as String
Dim marginright as Integer

//Vars
p=OpenPrinterDialog()
marginright=50

If p<>Nil Then

mynumber = format(15000.55, "###,###.00")
p.drawstring(mynumber, (p.width-p.stringwidth(mynumber))-marginright, 100)

mynumber = format(7000, "###,###.00")
p.drawstring(mynumber, (p.width-p.stringwidth(mynumber))-marginright, 120)

mynumber = format(11000.33, "###,###.00")
p.drawstring(mynumber, (p.width-p.stringwidth(mynumber))-marginright, 140)   

End If

`

@Elvis Agamez
No offense, but just a little hint.

Instead of and tag, you can use a button at the top-right of the reply area.
The page icon with the < > in it.
You can also use the square brackets [ and ] in combination with ‘code’ and ‘/code’, instead of the < and > you used.
This makes your code much more readable.

Dim p as Graphics
Dim mynumber as String
Dim marginright as Integer

//Vars
p=OpenPrinterDialog()
marginright=50

If p<>Nil Then

  mynumber = format(15000.55, "###,###.00")
  p.drawstring(mynumber, (p.width-p.stringwidth(mynumber))-marginright, 100)

  mynumber = format(7000, "###,###.00")
  p.drawstring(mynumber, (p.width-p.stringwidth(mynumber))-marginright, 120)

  mynumber = format(11000.33, "###,###.00")
  p.drawstring(mynumber, (p.width-p.stringwidth(mynumber))-marginright, 140)

End If

Hi Paul,

Thank you for your suggestion. I’ll keep it on mind on the next comment.