急!vb程序挂起的问题
Form1 code:
Public num As IntegerPrivate Sub Command1_Click() Timer1.Enabled = True Timer1.Interval = 1000End SubPrivate Sub Timer1_Timer() num = num + 1 WebBrowser1(num - 1).Navigate2 ("http://www.baidu.com") If num = 2 Then Timer1.Enabled = False num = 0 End IfEnd SubPrivate Sub WebBrowser1_DocumentComplete(index As Integer, ByVal pDisp As Object, URL As Variant) On Error Resume Next If (pDisp Is WebBrowser1(index).Object) Then 'MsgBox ("haha") Form2.Text1.Text = index Form2.Show 1 End IfEnd Sub
Private Sub Command1_Click() Unload Form2End Sub
Option ExplicitPublic num As IntegerPrivate Sub cmdCommand1_Click() Timer1.Enabled = True Timer1.Interval = 1000End SubPrivate Sub Form_Initialize() Status = FalseEnd SubPrivate Sub Timer1_Timer() If num = 0 Then num = num + 1 WebBrowser1(num - 1).Navigate2 ("http://www.baidu.com") Status = False ElseIf Status = True Then num = num + 1 WebBrowser1(num - 1).Navigate2 ("http://www.baidu.com") Status = False End If If num = 3 Then Timer1.Enabled = False num = 0 End If End SubPrivate Sub WebBrowser1_DocumentComplete(index As Integer, ByVal pDisp As Object, URL As Variant)On Error Resume Next If (pDisp Is WebBrowser1(index).Object) Then' MsgBox "haha" Form2.txtText1.Text = index Form2.Show 1 End If End Sub
[解决办法]
vb里的form并非模式窗口。建议把Num的改变用按钮来控制。