by Jafo C - Null (3 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Wed 1st May 2002
Date Added: Mon 8th February 2021
Rating:
(1 Votes)
Set caption to a PictureBox
'SetPicCapt: Set caption to a picbox
'You must set the Font properties from the PicBox Properties
'This code will work with forms too(If an error just Modify)
Sub SetPicCapt(DestObject As PictureBox, ByVal Caption As String)
Dim intX As Integer, intY As Integer, IntWidth As Integer, IntHeight As Integer
DestObject.AutoRedraw = True
IntWidth = DestObject.TextWidth(Caption)
IntHeight = DestObject.TextHeight(Caption)
intX = DestObject.Width / 2 - IntWidth / 2
intY = DestObject.Height / 2 - IntHeight / 2
DestObject.CurrentX = intX
DestObject.CurrentY = intY
DestObject.Print Trim$(Caption)
End Sub