标题:关于一个图片滚动的程序
只看楼主
yuiolivia
Rank: 1
等 级:新手上路
帖 子:41
专家分:0
注 册:2005-12-5
 问题点数:0 回复次数:2 
关于一个图片滚动的程序

Dim num, time As Integer
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
Dim show As Integer
If Timer1.Enabled Then
show = MsgBox("还看照片吗?", MsgBoxStyle.YesNo + MsgBoxStyle.Information + MsgBoxStyle.DefaultButton1, "选择")
If show = MsgBoxResult.Yes Then
Timer1.Stop()
End If
Else
Timer1.Start()
End If
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
PictureBox1.Image = ImageList1.Images(num)
num = (num + 1) Mod time
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
num = ImageList1.Images.Count
time = 0
End Sub

出现了这个错误,高手们指点一下,谢谢!

搜索更多相关主题的帖子: MsgBoxStyle show 滚动 
2006-10-22 11:00
lkjkf
Rank: 1
等 级:新手上路
帖 子:66
专家分:0
注 册:2005-4-21
得分:0 

我认为有可能是ImageList控件Images的索引值错了,每个图片的序号是从0开始的,也就是说,你最后一个图片的索引号是ImageList1.Images.Count - 1 的值,当你把ImageList1.Images.Count的值赋给num , 然后在PictureBox1.Image = ImageList1.Images(num)时就错了,括号里应该是(num-1)


 夫君子之行,静以修身,俭以养德,非淡泊无以明志,非宁静无以致远。
2006-10-24 10:58
梓风
Rank: 2
等 级:新手上路
威 望:4
帖 子:181
专家分:0
注 册:2006-10-22
得分:0 
Dim num As Integer = 1
Dim i As Integer = 0
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
Dim show As Integer
If i Mod 2 = 0 Then
PictureBox1.Image = ImageList1.Images(num - 1)
i = i + 1
Else
show = MsgBox("还看照片吗?", MsgBoxStyle.YesNo + MsgBoxStyle.Information + MsgBoxStyle.DefaultButton1, "选择")
If show = MsgBoxResult.Yes Then
PictureBox1.Image = ImageList1.Images(num - 1)
Else
num = num + 1
If num <= ImageList1.Images.Count Then
PictureBox1.Image = ImageList1.Images(num - 1)
Else
MsgBox("图片已经看完", MsgBoxStyle.Information, "提示")
End If
End If
End If
End Sub

等待相逢
2006-10-25 17:34



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-97917-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.148129 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved