问:在一个床体中设置了2个命令按钮,Command1,Command2。Commamd1执行一个费时的操作,包括调用多个过程和函数,而Command2则是终止/暂停Command1的运行,不是退出该程序,不知用VB5.0如何解决? 答:你可以采用一种变通的方法,在程序中定义一个Boolean变量,在执行command1中的程序时监视该变量,如果为False退出程序,在command2中加入代码,只要点击command2就将该变量设置为False下面是例程 Dim bMark As Boolean Private Sub Command1_Click() bMark = True For I = 1 To 150000 ' Start loop. DoEvents ' Yield to operating system. Text1.Text = Str(I) If Not bMark Then Exit Sub End If Next I ' Increment loop counter End Sub
Private Sub Command2_Click() bMark = False End Sub
问:有位大侠编了如下代码: Private Sub cmdCalendar_Click() Dim UserDate As Date
UserDate = CVDate(txtDate) If frmCalendar.GetDate(UserDate) Then txtDate = UserDate End If End Sub  
|