Private Sub Command1_Click() '开始摇奖的控件
Command2.SetFocus
Dim intranum, a, j As Integer, i As Long
Randomize
For i = 0 To 9999 ' 用来循环
intranum = Int(100 * Rnd) + 1
a = 0
For j = 0 To 1000 ' 用来延时
a = a + 1
Next j
Text1.Text = CStr(intranum)
Text1.Refresh
Next i
Text1.Text = CStr(intranum)
End Sub
Private Sub Command2_Click() ' 是我自己想设置一个结束的控件,如何来实现它?
Text1.Enabled = False
End Sub
Private Sub Command3_Click() ' 清除文本框
Text1.Text = ""
Command1.SetFocus
End Sub
Private Sub Command4_Click()
End
End Sub
Private Sub Form_Activate()
Command1.SetFocus
End Sub
我的问题是: 如何用第二个命令控件来结束循环?
谢谢!!!!!!!!!!!! 各位大哥,大姐
9 个解决方案
#1
用下面代码:
Dim i As Integer
Dim IsStop as Boolean '// 停止标志
Private Sub Command1_Click() '开始摇奖的控件
Command2.SetFocus
isstop=false
Dim intranum, a, j As Integer, i As Long
Randomize
For i = 0 To 9999 ' 用来循环
if IsStop then exit for '// 停止
intranum = Int(100 * Rnd) + 1
a = 0
For j = 0 To 1000 ' 用来延时
if IsStop then exit for '// 停止
a = a + 1
doevents
Next j
Text1.Text = CStr(intranum)
Text1.Refresh
doevents
Next i
Text1.Text = CStr(intranum)
End Sub
Private Sub Command2_Click() ' 是我自己想设置一个结束的控件,如何来实现它?
isstop=true '// 停止为真
Text1.Enabled = False
End Sub
Private Sub Command3_Click() ' 清除文本框
Text1.Text = ""
Command1.SetFocus
End Sub
Private Sub Command4_Click()
End
End Sub
Private Sub Form_Activate()
Command1.SetFocus
End Sub
Dim i As Integer
Dim IsStop as Boolean '// 停止标志
Private Sub Command1_Click() '开始摇奖的控件
Command2.SetFocus
isstop=false
Dim intranum, a, j As Integer, i As Long
Randomize
For i = 0 To 9999 ' 用来循环
if IsStop then exit for '// 停止
intranum = Int(100 * Rnd) + 1
a = 0
For j = 0 To 1000 ' 用来延时
if IsStop then exit for '// 停止
a = a + 1
doevents
Next j
Text1.Text = CStr(intranum)
Text1.Refresh
doevents
Next i
Text1.Text = CStr(intranum)
End Sub
Private Sub Command2_Click() ' 是我自己想设置一个结束的控件,如何来实现它?
isstop=true '// 停止为真
Text1.Enabled = False
End Sub
Private Sub Command3_Click() ' 清除文本框
Text1.Text = ""
Command1.SetFocus
End Sub
Private Sub Command4_Click()
End
End Sub
Private Sub Form_Activate()
Command1.SetFocus
End Sub
#2
要结贴给分哦
#3
对,doevents是让程序把控制权暂时交给系统,响应系统事件及其它控件产生的事件,然后回来继续执行程序.
#4
其实,不如把上面的循环放在计时器里进行,效果会更多,以后阅读理解起来也更容易.
#5
打错字了
不如把上面的循环放在计时器里进行(可以不用DOEVENTS及延时了).效果会更好,以后阅读理解起来也更容易.
不如把上面的循环放在计时器里进行(可以不用DOEVENTS及延时了).效果会更好,以后阅读理解起来也更容易.
#6
楼主可以将
Randomize
For i = 0 To 9999 ' 用来循环
intranum = Int(100 * Rnd) + 1
a = 0
For j = 0 To 1000 ' 用来延时
a = a + 1
Next j
Text1.Text = CStr(intranum)
Text1.Refresh
Next i
这段代码置于 Timer事件中,然后,开始按钮中写入 Timer.Enable=True,停止按钮中写 Timer.Enable=False,另外,可以调整Timer的Interval属性值,来控制Timer事件间隔的毫秒数!
偶就是这么写的!
Randomize
For i = 0 To 9999 ' 用来循环
intranum = Int(100 * Rnd) + 1
a = 0
For j = 0 To 1000 ' 用来延时
a = a + 1
Next j
Text1.Text = CStr(intranum)
Text1.Refresh
Next i
这段代码置于 Timer事件中,然后,开始按钮中写入 Timer.Enable=True,停止按钮中写 Timer.Enable=False,另外,可以调整Timer的Interval属性值,来控制Timer事件间隔的毫秒数!
偶就是这么写的!
#7
偶前天刚写了一个可以指定抽奖号码的小东东!
#8
谢谢!!!!!!!!!
#9
第一次来发帖子
有什么不妥之处还请多多包函!!!!!
有什么不妥之处还请多多包函!!!!!
#1
用下面代码:
Dim i As Integer
Dim IsStop as Boolean '// 停止标志
Private Sub Command1_Click() '开始摇奖的控件
Command2.SetFocus
isstop=false
Dim intranum, a, j As Integer, i As Long
Randomize
For i = 0 To 9999 ' 用来循环
if IsStop then exit for '// 停止
intranum = Int(100 * Rnd) + 1
a = 0
For j = 0 To 1000 ' 用来延时
if IsStop then exit for '// 停止
a = a + 1
doevents
Next j
Text1.Text = CStr(intranum)
Text1.Refresh
doevents
Next i
Text1.Text = CStr(intranum)
End Sub
Private Sub Command2_Click() ' 是我自己想设置一个结束的控件,如何来实现它?
isstop=true '// 停止为真
Text1.Enabled = False
End Sub
Private Sub Command3_Click() ' 清除文本框
Text1.Text = ""
Command1.SetFocus
End Sub
Private Sub Command4_Click()
End
End Sub
Private Sub Form_Activate()
Command1.SetFocus
End Sub
Dim i As Integer
Dim IsStop as Boolean '// 停止标志
Private Sub Command1_Click() '开始摇奖的控件
Command2.SetFocus
isstop=false
Dim intranum, a, j As Integer, i As Long
Randomize
For i = 0 To 9999 ' 用来循环
if IsStop then exit for '// 停止
intranum = Int(100 * Rnd) + 1
a = 0
For j = 0 To 1000 ' 用来延时
if IsStop then exit for '// 停止
a = a + 1
doevents
Next j
Text1.Text = CStr(intranum)
Text1.Refresh
doevents
Next i
Text1.Text = CStr(intranum)
End Sub
Private Sub Command2_Click() ' 是我自己想设置一个结束的控件,如何来实现它?
isstop=true '// 停止为真
Text1.Enabled = False
End Sub
Private Sub Command3_Click() ' 清除文本框
Text1.Text = ""
Command1.SetFocus
End Sub
Private Sub Command4_Click()
End
End Sub
Private Sub Form_Activate()
Command1.SetFocus
End Sub
#2
要结贴给分哦
#3
对,doevents是让程序把控制权暂时交给系统,响应系统事件及其它控件产生的事件,然后回来继续执行程序.
#4
其实,不如把上面的循环放在计时器里进行,效果会更多,以后阅读理解起来也更容易.
#5
打错字了
不如把上面的循环放在计时器里进行(可以不用DOEVENTS及延时了).效果会更好,以后阅读理解起来也更容易.
不如把上面的循环放在计时器里进行(可以不用DOEVENTS及延时了).效果会更好,以后阅读理解起来也更容易.
#6
楼主可以将
Randomize
For i = 0 To 9999 ' 用来循环
intranum = Int(100 * Rnd) + 1
a = 0
For j = 0 To 1000 ' 用来延时
a = a + 1
Next j
Text1.Text = CStr(intranum)
Text1.Refresh
Next i
这段代码置于 Timer事件中,然后,开始按钮中写入 Timer.Enable=True,停止按钮中写 Timer.Enable=False,另外,可以调整Timer的Interval属性值,来控制Timer事件间隔的毫秒数!
偶就是这么写的!
Randomize
For i = 0 To 9999 ' 用来循环
intranum = Int(100 * Rnd) + 1
a = 0
For j = 0 To 1000 ' 用来延时
a = a + 1
Next j
Text1.Text = CStr(intranum)
Text1.Refresh
Next i
这段代码置于 Timer事件中,然后,开始按钮中写入 Timer.Enable=True,停止按钮中写 Timer.Enable=False,另外,可以调整Timer的Interval属性值,来控制Timer事件间隔的毫秒数!
偶就是这么写的!
#7
偶前天刚写了一个可以指定抽奖号码的小东东!
#8
谢谢!!!!!!!!!
#9
第一次来发帖子
有什么不妥之处还请多多包函!!!!!
有什么不妥之处还请多多包函!!!!!