VB编程新手问题
用滚动条实现四张图片的切换
括号里面怎么放多张图片,我要用滚动条实现切换图片
Private Sub HScroll1_Change()
image1.picture=loadpicture()
End Sub
最佳答案
'例:窗体添加HScroll1、Image1、File1控件
Private Sub Form_Load()
'假设切换5张图片
HScroll1.Min = 0
HScroll1.Max = 4
'假设图片保存位置为d:\test
File1.Path = "d:\test"
File1.Pattern = "*.jpg;*.bmp"
Image1.Stretch = True '自动调整图片大小
If File1.ListCount > 0 Then
File1.ListIndex = 0
Call HScroll1_Change '显示第1张图片
End If
End Sub
Private Sub HScroll1_Change()
If File1.ListCount = 0 Then Exit Sub
If HScroll1.Max > File1.ListCount - 1 Then Exit Sub
File1.ListIndex = HScroll1.Value '根据HScroll1的值定位图片
Image1.Picture = LoadPicture(File1.Path & "\" & File1.List(File1.ListIndex))
End Sub
布局截图
运行过程动画
其他回答
暂无其它回答!