tags:

views:

231

answers:

4
for a=0 to 1000
lable.text=a
next

above loop does not update the text status of lable, while loop is running, it updates only at the end of for loop, but i tried with vb6.0 it is possible by using Do events. but i dont know what is the function in vb2010 beta 2. plz help me to solve this problem.

+1  A: 

You could try

Application.DoEvents()

Or even

lable.Refresh()

astander
A: 

Your question is not very clear, but I'll try to explain what I understood. The loop actually updates it, but it happens so fast that you only see the final value. I don't know the VB equilevant of sleep() method, but you should be able to find it in web pretty quickly.

Erkan Haspulat
A: 

Its not the text is not getting changed but its getting overwritten when you loop it each time. If you want to display 0 to 1000 in the label then you have to append the value.

zapping
+1  A: 

You need to change the way you think about this sort of problem in .NET - DoEvents was a hack to deal with the lack of threading in VB, useful but not a good solution.

To run a processor intensive task while keeping the UI responsive you need to use multi-threading, you kick off the intensive work in a separate thread and update the UI in the main thread.

Easiest way to do this is using the BackgroundWorker class http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker(VS.100).aspx

Your loop would raise ReportProgress events which your UI code would use to update the label.

Murph