如何表示偶数?

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显示,是不是我表示偶数的方法不对?程序运行后没有预期的目的
...全文
423 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
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。。。。
用户 昵称 2003-01-06
  • 打赏
  • 举报
回复
if oushu/2=int(oushu/2) then
true
end if

7,785

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧