- 积分
- 2723
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2012-4-19
- 最后登录
- 1970-1-1
![未绑定新浪微博用户 新浪微博达人勋](source/plugin/sina_login/img/gray.png)
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
最近在研究vb,使用image图像框装载适合比例大小的图片,但是我的代码总是提示溢出,自己找不到问题的原因,请高手指点,谢谢您!附代码如下:
Private Sub Command1_Click()
Image1.Picture = LoadPicture(App.Path & "\" & "a.jpg")
End Sub
Private Sub Command2_Click()
Dim a As Integer
Dim b As Integer 'a 是高度,b是宽度
Dim h As Integer
Dim w As Integer
Image1.Stretch = False
h = Image1.Height
w = Image1.Width
a = Image1.Picture.Height
b = Image1.Picture.Width
If h / a <= w / b Then
Image1.Stretch = True
Image1.Width = b
Image1.Height = h * b / w
Else
Image1.Stretch = True
Image1.Width = w * a / h
Image1.Height = a
End If
End Sub
画红线为提示错误项,拜请指点!
|
|