以下代码可供实现:
注意:PicFileName 为图片文件的完整路径
picPhoto 为PictureBox控件
要在工程中引用"OLE Automation"Sub LoadPic(ByVal PicFileName As String)
Dim p As stdole.StdPicture
Dim iPicX As Long '图片文件的宽度
Dim iPicY As Long '图片文件的高度
If PicFileName = "" Then
Set picPhoto.Picture = Nothing
Exit Sub
End If
'取得图片的长宽信息(单位:缇)
Set p = VB.LoadPicture(PicFileName)
iPicX = frmProduct.ScaleX(p.Width, 8, 1)
iPicY = frmProduct.ScaleY(p.Height, 8, 1) Set picPhoto.Picture = Nothing
picPhoto.PaintPicture p, (picPhoto.Width - iPicX) / 2, (picPhoto.Height - iPicY) / 2End Sub
注意:PicFileName 为图片文件的完整路径
picPhoto 为PictureBox控件
要在工程中引用"OLE Automation"Sub LoadPic(ByVal PicFileName As String)
Dim p As stdole.StdPicture
Dim iPicX As Long '图片文件的宽度
Dim iPicY As Long '图片文件的高度
If PicFileName = "" Then
Set picPhoto.Picture = Nothing
Exit Sub
End If
'取得图片的长宽信息(单位:缇)
Set p = VB.LoadPicture(PicFileName)
iPicX = frmProduct.ScaleX(p.Width, 8, 1)
iPicY = frmProduct.ScaleY(p.Height, 8, 1) Set picPhoto.Picture = Nothing
picPhoto.PaintPicture p, (picPhoto.Width - iPicX) / 2, (picPhoto.Height - iPicY) / 2End Sub
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货