我VB菜鸟,帮忙看看哪儿错了

来源:百度知道 编辑:UC知道 时间:2024/06/15 14:41:26
Dim x As Integer
Dim iwidth As Integer
Dim iheight As Integer
Private Sub form_load()
Picture1.Picture = LoadPicture("f:\1.jpg")
Frame1.Caption = "现在显示的是第一张图片"
x = 2
End Sub
Private Sub command1_click()
If x = 2 Then
Picture1.Picture = LoadPicture("f:\2.jpg")
Frame1.Caption = "现在显示的是第二张图片"
x = 1
ElseIf x = 1 Then
Picture1.Picture = LoadPicture("f:\1.jpg")
Frame1.Caption = "现在显示的是第一张图片"
x = 2
End If
End Sub
Private Sub check1_change()
If Check1.Value = 1 Then
Picture1.AutoSize = True
Picture1.Height = iheight
Picture1.Width = iwidth
Else
Picture1.AutoSize = False
Picture1.Height = iheight
Picture1.Width = iwidth
End If
End Sub

说明:check1为勾选框 picture为图像框 frame1为一个标签 command1为按钮
现在按按钮标签和图片会自动换,没有问题
可是勾上勾,图片不会自动变换大小适应图像框,为什么

Picture1.AutoSize = True 后Picture1自动调整大小,无法通过程序手动控制其大小了。Picture1.AutoSize = True下面两句
Picture1.Height = iheight
Picture1.Width = iwidth
执行了也没有效果,Height,Width不能设置其值。只有在Picture1.AutoSize = False下这两句才有执行产生效果

Picture1.AutoSize = True
这句是让picture1适应图像大小,不是图像适应picture1哦
要让图像随控件尺寸走就用image吧,stretch属性设为true就可以了