Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Colon at the end of excel file name(ex: problem.xls:1, problem.xls financeguy New Users to Excel 2 January 15th 10 01:15 AM
Started out as an Access problem. Now an Excel problem RobertM Excel Discussion (Misc queries) 2 April 26th 06 07:30 PM
problem with a conditional max problem Brian Cornejo Excel Discussion (Misc queries) 1 February 18th 05 06:25 PM
Problem when multipple users access shared xl-file at the same time, macrocode for solve this problem? OCI Excel Programming 0 May 16th 04 10:40 PM


All times are GMT +1. The time now is 08:51 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"