简单图片按钮的实现

前端之家收集整理的这篇文章主要介绍了简单图片按钮的实现前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

VB的标准命令按钮CommandButton可以实现图片按钮,并且按钮文字可以居中。

Option Explicit
'Form1上添加一个图片框控件Picture1,一个命令按钮Command1
Private Sub Form_Load()
    
   Picture1.Picture = LoadPicture("F:\资料\My Pictures\2006Spring2-西湖美景.jpg")
   Command1.Caption = "我的图片按钮"
   
   Picture1.AutoRedraw = True
   With Picture1.Font
        .Name = Command1.Caption
        .Bold = True
        .Size = 24
   End With
   
   Picture1.CurrentX = (Picture1.Width - Picture1.TextWidth(Command1.Caption)) / 2
   Picture1.CurrentY = (Picture1.Height - Picture1.TextHeight(Command1.Caption)) / 2
   Picture1.ForeColor = RGB(255,255,255)
   Picture1.Print Command1.Caption
   
   Command1.Caption = ""
   Set Command1.Picture = Picture1.Image
   
End Sub


效果图如下:

原文链接:https://www.f2er.com/vb/258744.html

猜你在找的VB相关文章