Does anyone know the best way to refresh a form when in the middle of a complex loop without adding to much time to the loop itself.
Printable View
Does anyone know the best way to refresh a form when in the middle of a complex loop without adding to much time to the loop itself.
I reckon this might work:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_PAINT = &HF
Private Sub RefreshForm()
'probably best to move this line out of the proc,
'and into the looping procedure instead of
'calling refreshform every time
SendMessage Form1.hwnd, WM_PAINT, Form1.hDC, 0&
End Sub
This will refresh form1 20 times in 10000 loopsCode:For x=0 to 10000
if x mod 500=0 then form1.refresh:doevents
next x
Cheers Guys
Muchos Graciasssss!!!!!!!!!!!!!!!!!1
Refresh should fire off the repaint itself, you should not require the DoEvents.