VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Correct way to insert and center text on a picture!

by Mark Balthazor (1 Submission)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 23rd August 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Correct way to insert and center text on a picture!

Rate Correct way to insert and center text on a picture!




Label1.Font.Name = Text1.Font.Name
Label1.Font.Size = Text1.Font.Size
Label1.Font.Bold = Text1.Font.Bold
Label1.Caption = Text1.Text
Picture1.Font.Size = Text1.Font.Size
Picture1.Font.Name = Text1.Font.Name
Picture1.Font.Bold = Text1.Font.Bold
Picture1.Font.Italic = Text1.Font.Italic
Picture1.Font.Underline = Text1.Font.Underline
Picture1.Font.Strikethrough = Text1.FontStrikethru
Picture1.ForeColor = Text1.ForeColor
'This sets the picturebox text font to whatever the textbox is, and also ensures that the label will autosize to whatever the text size is.

Picture1.CurrentX = (Picture1.ScaleWidth / 2) - (label1.width / 2) 
Picture1.CurrentY = (Picture1.ScaleHeight / 2) - (label1.height / 2)
'This uses the dimensions of the label to center the text on the picturebox.

Picture1.Print Text1.Text
Picture1.Picture=Picture1.Image
'This prints the text to the picturebox. That's it!

Download this snippet    Add to My Saved Code

Correct way to insert and center text on a picture! Comments

No comments have been posted about Correct way to insert and center text on a picture!. Why not be the first to post a comment about Correct way to insert and center text on a picture!.

Post your comment

Subject:
Message:
0/1000 characters