in any loops in your code insert the line DoEvents, this lets VB handle everything that needs doing, and then continued with your code
eg This is a bit of code that paints a parrern your form (if it's 255 pixels by 255 pixels and it's scalemoed is pixels, otherwise it's pretty useless)
Code:
For i = 1 to 255
For j = 1 to 255
Form1.PSet (i,j), RGB(255 * Rnd, i, j)
Next j
Next i
this takes a couple of seconds during which you can't move your form or click buttons
if you insert the line DoEvents
Code:
For i = 1 to 255
DoEvents
For j = 1 to 255
Form1.PSet (i,j), RGB(255 * Rnd, i, j)
Next j
Next i
then the code will run a little slower but you can move your form etc.
Be carefull about doing this in a timer however, if your timer is set to 500 ms and the code takes 600 ms to operate then the first execution of the code will pause and wait for the second to start, then this execution will be interupted by the next and soon you will have hundreds of executions open and you will slowly run out of memory. If this code was in a timer I would do this
Code:
Private Sub Timer1_Timer()
Static boolCodeRunning As Boolean
Dim i As Integer
Dim j As Integer
If Not boolCodeRunning Then
boolCodeRunning = True
For i = 0 To 255
DoEvents
For j = 0 To 255
Picture1.PSet (i, j), RGB(255 * Rnd, i, j)
Next j
Next i
boolCodeRunning = False
End If
End Sub
this prevents the code from running twice at the same time, if it hasn't finished then it just skips.