Declare Function CreateThread Lib "kernel32" _ (lpThreadAttributes As Any, ByVal dwStackSize As Long, _ ByVal lpStartAddress As Long, ByVal lpParameter As Long, _ LpThreadId ByVal dwCreationFlags As Long, As Long) As Long Dim Out3 As Long
Simple call:
Sub Test1 () Dim the lp As Long, LLP As Long, As Long x Lp=1000 X=CreateThread (Null, ByVal 0 & amp; The AddressOf z_pHandle OutText3, Varptr (lp), ByVal 0 & amp; , ThreadID1) R=WaitForSingleObject (x, - 1) The Debug. Print Out3 & amp; "!" End Sub Sub OutText3 (b As Long) Out3=C * 2 End Sub
Lp values passed less than 1000 b, why?
CodePudding user response:
The lp is defined as a global variable to try again
CodePudding user response:
First this sb never believe upstairs. The second Sub OutText3 (b As Long) Out3=C * 2 End Sub
B and out3 have relations? Sub OutText3 (b As Long) Out3=b * 2 End Sub
CodePudding user response:
Separately, and then under vb use CreateThread thread is not very stable, because most of the vb controls are not thread-safe And multi-threaded debugging very trouble. A collapse would soon end I saw you again a bit code You Sub Test1 () in the main thread calls the Debug. Print Out3 & amp; "!" Nine times out of ten is not the correct output The Debug. Print Out3 & amp; "!" You try to Out3=b * 2 Should be ok
CodePudding user response:
Sub OutText3 As Long (b) Out3=C * 2 The Debug. Print Out3 & amp; "!" End Sub