Graphic Text Centering

I am trying to centre the text in a grid on a picture with stringwidth and height and the xbox and ybox as the grid box dimensions without luck. It looks fine when first draw but when the window is resized the scaling doesn’t match up. Is it possible or am I chasing my tail?

buffpicture.graphics.TextFont = "Arial"
'make sure the letter fits in box
if xbox < ybox then
  buffpicture.graphics.TextSize = xbox*.7
else
  buffpicture.graphics.TextSize = ybox*.7
end if
buffpicture.graphics.ForeColor = rgb(0, 0, 255)   
'
sw = ((xbox - buffpicture.Graphics.StringWidth(letter(xx,yy)))/2)-2
sh = ((ybox - buffpicture.Graphics.StringHeight(letter(xx,yy),100))/2)
if plettercase = 1 then
  buffpicture.Graphics.DrawString letter(xx,yy),cursx+sw,cursy+ybox-sh
else
  buffpicture.Graphics.DrawString lowercase(letter(xx,yy)),cursx+sw,cursy+ybox-sh
end if

end if

For the vertical distance, try this:

dim g as graphics = buffpicture.graphics // for simplicity sh = (ybox + g.TextAscent * 0.8) / 2

Thanks Greg