I put the parathesis on the wrong one is all. Try this:
VB Code:
iX = 560 + ((200 - CInt(invSize.Width)) / 2) e.Graphics.DrawString("Invoice Number", bFont, Brushes.Black, iX, 250)
The fact that is does the division first is what messed it up.
Here is how I tested:
VB Code:
Dim txt As String = "Center Me Please" Dim defFont As New Font("Tahoma", 14) Dim boxStartx As Integer = 560 Dim boxStarty As Integer = 275 Dim boxWidth As Integer = 200 Dim txtSize As SizeF = e.Graphics.MeasureString(txt, defFont) Dim start As Integer = boxStartx + ((boxWidth - Convert.ToInt32(txtSize.Width)) / 2) e.Graphics.DrawString(txt, defFont, Brushes.Black, start, boxStarty) e.Graphics.DrawRectangle(New Pen(Color.Black), boxStartx, boxStarty, 200, 30)




Reply With Quote