Code: Select all
Option Explicit
Private Sub Command1_Click()
Call DrawText
End Sub
Private Sub DrawText()
Const SAMPLE_TEXT As String = "0123456789"
' Draw on the picture.
Me.Picture1.Font.Name = "ARIAL"
Me.Picture1.Font.Size = 24
Me.Picture1.Font.Bold = True
Me.Picture1.ForeColor = vbBlack
' Center the text horizontally at the top of the picture.
Me.Picture1.CurrentX = (Me.Picture1.ScaleWidth - Me.Picture1.TextWidth(SAMPLE_TEXT)) / 2
Me.Picture1.CurrentY = 0
Me.Picture1.AutoRedraw = True
Me.Picture1.Print SAMPLE_TEXT
' Make the text a permanent part of the image.
' This is important if you later need to copy
' the picture to another control or the Printer.
Me.Picture1.Picture = Me.Picture1.Image
End Sub
i need to center text in orizontal and vertical, possible?