一个vb的循环问题~~~在线等答案!!!!
我在VB里用IE控件浏览本机的12页网页,想让两个COMMAND按扭实现上翻页和下翻页,下翻页很顺利,但上翻页到12页时就翻不动了,代码如下,谁帮我看一下,那里有问题
这是下翻页的代码
Private Sub Command2_Click()
Label3.Caption = "当前是2007年"
i = Abs(i) '取i的绝对值
i = i - 1
If i = 1 Then
Label6.Caption = "一月" '在lbeal中显示当前的月份
WebBrowser1.Navigate "file:\\\C:\My Web Sites\一月.htm"
ElseIf i = 2 Then
Label6.Caption = "二月" '在lbeal中显示当前的月份
WebBrowser1.Navigate "file:\\\C:\My Web Sites\二月.htm"
ElseIf i = 3 Then
Label6.Caption = "三月" '在lbeal中显示当前的月份
WebBrowser1.Navigate "file:\\\C:\My Web Sites\三月.htm"
ElseIf i = 4 Then
Label6.Caption = "四月" '在lbeal中显示当前的月份
WebBrowser1.Navigate "file:\\\C:\My Web Sites\四月.htm"
ElseIf i = 5 Then
Label6.Caption = "五月" '在lbeal中显示当前的月份
WebBrowser1.Navigate "file:\\\C:\My Web Sites\五月.htm"
ElseIf i = 6 Then
Label6.Caption = "六月" '在lbeal中显示当前的月份
WebBrowser1.Navigate "file:\\\C:\My Web Sites\六月.htm"
ElseIf i = 7 Then
Label6.Caption = "七月" '在lbeal中显示当前的月份
WebBrowser1.Navigate "file:\\\C:\My Web Sites\七月.htm"
ElseIf i = 8 Then
Label6.Caption = "八月" '在lbeal中显示当前的月份
WebBrowser1.Navigate "file:\\\C:\My Web Sites\八月.htm"
ElseIf i = 9 Then
Label6.Caption = "九月" '在lbeal中显示当前的月份
WebBrowser1.Navigate "file:\\\C:\My Web Sites\九月.htm"
ElseIf i = 10 Then
Label6.Caption = "十月" '在lbeal中显示当前的月份
WebBrowser1.Navigate "file:\\\C:\My Web Sites\十月.htm"
ElseIf i = 11 Then
Label6.Caption = "十一月" '在lbeal中显示当前的月份
WebBrowser1.Navigate "file:\\\C:\My Web Sites\十一月.htm"
Else
Label6.Caption = "十二月" '在lbeal中显示当前的月份
WebBrowser1.Navigate "file:\\\C:\My Web Sites\十二月.htm"
End If
If i = 12 Then
i = 0
End If
End Sub
参考答案:应该在模块中定义PUBLIC变量I,这样II在全局中可以加减~~