有没有什么办法让两个过程齐头并进,同步执行?比如我有两个都是很长的循环过程,我想让他们完全同步开始,同步执行.
比如我有两个都是很长的循环过程,我想让他们完全同步开始,同步执行.
有可能吗?好像只能顺序执行?
多谢!!
[解决办法]
楼上都说了
循环中加了 DoEvents 甚至 sleep
然后将两过程放在事件过程中
主过程负责触发事件
timer最简单,但参数比较麻烦,所以自定义个,事件类的说,比较方便
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "clsEvents"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'''事件类,用于异步操作'''
''''
Public Event OpenFile(ByVal fileName As String)
Friend Function Raise(ByVal eName As String, Optional ByVal var As Variant)
Dim tName As String
tName = LCase(eName)
Select Case tName
Case "openfile": RaiseEvent OpenFile(CStr(var)) '打开文件事件
End Select
End Function
Private WithEvents Evt As clsEvents
Evt.Raise "OpenFile", fileName
Private Sub Evt_OpenFile(ByVal fName As String)
''文件打开事件
''Debug.Print priStream.Read
''WBIE.Document(1).body.innerhtml = priXml6.xml
''WBIE.LoadHTMLFromString 1, priXml6.xml, "http://www.baidu.com/"
Debug.Print priXml6.documentElement
End Sub