简单图片按钮的实现

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

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

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


效果图如下:

猜你在找的VB相关文章