永发信息网

VB Select语句 为什么赋值总为0?

答案:2  悬赏:0  手机版
解决时间 2021-02-02 11:27
  • 提问者网友:箛茗
  • 2021-02-02 07:02
Private Sub Form_Load()
Dim Motion As Integer
Motion = 1
Print Motion
End Sub
Private Sub Timer1_Timer()
Select Case Motion
Case 1
Label1.Left = Label1.Left + 50
Label1.Top = Label1.Top - 50
If Label1.Left >= Form1.Width Then
Motion = 2
ElseIf Label1.Top <= 0 Then
Motion = 3
End If
Case 2
Label1.Left = Label1.Left - 50
Label1.Top = Label1.Top - 50
If Label1.Left <= 0 Then
Motion = 1
ElseIf Label1.Top <= 0 Then
Motion = 4
End If
Case 3
Label1.Left = Label1.Left + 50
Label1.Top = Label1.Top + 50
If Label1.Left >= Form1.Width Then
Motion = 4
ElseIf Label1.Top >= Form1.Height Then
Motion = 1
End If
Case 4
Label1.Left = Label1.Left - 50
Label1.Top = Label1.Top + 50
If Label1.Left <= 0 Then
Motion = 3
ElseIf Label1.Top >= Form1.Height Then
Motion = 2
End If
End Select
End Sub

帮我看看这段代码 我用Form_load 赋值 Form我已设置Autoredraw改为true 但下面motion总为0 为什么
最佳答案
  • 五星知识达人网友:笑迎怀羞
  • 2021-02-02 07:52
Dim Motion As Integer '在通用过程内定义 全局变量

Private Sub Form_Load()
Motion = 1
Print Motion
End Sub
Private Sub Timer1_Timer()
Select Case Motion
Case 1
Label1.Left = Label1.Left + 50
Label1.Top = Label1.Top - 50
If Label1.Left >= Form1.Width Then
Motion = 2
ElseIf Label1.Top <= 0 Then
Motion = 3
End If
Case 2
Label1.Left = Label1.Left - 50
Label1.Top = Label1.Top - 50
If Label1.Left <= 0 Then
Motion = 1
ElseIf Label1.Top <= 0 Then
Motion = 4
End If
Case 3
Label1.Left = Label1.Left + 50
Label1.Top = Label1.Top + 50
If Label1.Left >= Form1.Width Then
Motion = 4
ElseIf Label1.Top >= Form1.Height Then
Motion = 1
End If
Case 4
Label1.Left = Label1.Left - 50
Label1.Top = Label1.Top + 50
If Label1.Left <= 0 Then
Motion = 3
ElseIf Label1.Top >= Form1.Height Then
Motion = 2
End If
End Select
End Sub
全部回答
  • 1楼网友:夜风逐马
  • 2021-02-02 09:12
private sub form_click() n = inputbox(";") select case n case 2, 4, 6 x = 20 case is < 10 x = 30 case 10 x = 40 case 1 to 20 x = 10 end select msgbox (x) end sub 你把case 1 to 20 x = 10 放前面,田间符合就不会执行下面的语句了~
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯