如何表示偶数?

wandering_hawk 2003-01-06 01:44:10
Dim i as integer, j As Integer
Private Sub Form_Load()
i = 1
Timer1.Interval = 500
End Sub

Private Sub Timer1_Timer()
i = i + 1
If i = 2 * j Then
Frame2.Visible = False
Frame1.Visible = True
Else
Frame1.Visible = False
Frame2.Visible = True
End If
End Sub


我的目的是让frame1,2交替显示,也就是i为偶数时frame1显示,i为奇数时frame2显示,是不是我表示偶数的方法不对?程序运行后没有预期的目的
...全文
159 点赞 收藏 7
写回复
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
cupidvenus 2003-01-06
Dim i as integer, j As Integer
Private Sub Form_Load()
i = 1
Timer1.Interval = 500
End Sub

Private Sub Timer1_Timer()
i = (i + 1) mod 2
If i <> 0 Then
Frame1.Visible = True
Else
Frame1.Visible = False
End If
Frame2.Visible = Not Frame1.Visible
End Sub
回复
Sean918 2003-01-06
判断奇偶数用 mod 运算符
回复
LiuHaisky 2003-01-06
Dim i as integer, j As Integer
Private Sub Form_Load()
i = 1
Timer1.Interval = 500
End Sub

Private Sub Timer1_Timer()
i = i + 1
Frame1.Visible = i mod 2
Frame2.Visible = Not Frame1.Visible
End Sub
回复
jinesc 2003-01-06
这样不更好吗?
Private Sub Timer1_Timer()
If Frame2.Visible = True Then
Frame2.Visible = False
Frame1.Visible = True
Else
Frame1.Visible = False
Frame2.Visible = True
End If
End Sub
回复
wangweicai 2003-01-06
Dim i as integer, j As Integer
Private Sub Form_Load()
i = 1
Timer1.Interval = 500
End Sub

Private Sub Timer1_Timer()
i = i + 1
If (i mod 2)<>0 Then
Frame2.Visible = False
Frame1.Visible = True
Else
Frame1.Visible = False
Frame2.Visible = True
End If
End Sub

回复
skoin007 2003-01-06
用MOD函数啊,i除以2取余,为零的话。。。。,else。。。。
回复
if oushu/2=int(oushu/2) then
true
end if
回复
发动态
发帖子
VB基础类
创建于2007-09-28

7449

社区成员

VB 基础类
申请成为版主
社区公告
暂无公告