这是我的代码(部分),当客人猜到3次时。
If (counter = 3) And (rx.EOF = True) Then
MsgBox "You guessed too many times! Intruder alert!"
End
.
.
.
是否有最好的方法来结束/冻结此用户以保护程序? 任何想法都会有所帮助。
答案 0 :(得分:2)
End is evil。 End
已被弃用in the VB6 manual,因为它会抑制Form_Unload
和Class_Terminate
等清理事件。以下是VB6手册End
topic的摘录:
注意 End语句会停止代码 突然执行。 您放入卸载的代码, QueryUnload和Terminate事件 表单和类模块不是 执行......
End语句提供了一种方法 强迫你的程序停止。对于正常 终止Visual Basic程序, 你应该卸载所有表格。
答案 1 :(得分:1)
您可以卸载所有表单
例如,一个允许您加载额外表单并将其全部卸载的项目
'1 form with:
' 2 command buttons: name=Command1 name=Command2
Option Explicit
Private Sub Command1_Click()
Dim frm As New Form1
frm.Caption = CStr(Now)
frm.Show
End Sub
Private Sub Command2_Click()
UnloadAll
End Sub
Private Sub Form_Load()
Command1.Caption = "load extra"
Command2.Caption = "unload all"
End Sub
Private Sub UnloadAll()
Dim frm As Form
For Each frm In Forms
If frm.hWnd <> Me.hWnd Then
Unload frm
End If
Next frm
Unload Me
End Sub
如果你有任何(无休止的)循环运行,请小心。你需要确保先完成这些。 还要注意连接到其他设备/应用程序/...
的控件