Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
it's a problem about multithread in vba:
------------------begin macro-----------------------
'btnconfirm is a button on the user interface Private Sub btnConfirm_Click() 'run the process of analyzing in a new thread Dim tId As Long, hThread As Long hThread = CreateThreadL(0, 0, AddressOf DurativeFunc, 0, 0, tId) End Sub 'the following is parts of module1 Declare Function CreateThreadL Lib "kernel32" Alias "CreateThread" _ (ByVal lpThreadAttributes As Long, ByVal dwStackSize As Long, ByVal lpStartAddress As Long, _ ByVal lpParameter As Long, ByVal dwCreationFlags As Long, lpThreadId As Long) As Long Function DurativeFunc(ByVal lpvThreadParm As Long) As Long Dim dwResult As Long dwResult = 0 'problem: 'the following process(in fact it's a timeconsuming process,here just simplified) work well in a non-multithread function 'but here(as a multithread function) it only modify the content of cells(1,3) 'why??? For i = 1 To 10 ActiveSheet.Cells(i, 3) = i Next DurativeFunc = dwResult End Function ------------------------end macro--------------------- i just want to update the user interface(informing user of what's going on),when a time-consuming process is running. anyway if anyone gets time to help i would be very happy. any other method to solve the problem is appreciated. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Colon at the end of excel file name(ex: problem.xls:1, problem.xls | New Users to Excel | |||
Started out as an Access problem. Now an Excel problem | Excel Discussion (Misc queries) | |||
problem with a conditional max problem | Excel Discussion (Misc queries) | |||
Problem when multipple users access shared xl-file at the same time, macrocode for solve this problem? | Excel Programming |