This is a bit offtopic, but my eyes hurt when I see this kind of code and I have to reply
quote:
Originally posted by Matty.
code:
Public Function closeAll()
Dim imwindowclass As Long
10 imwindowclass = FindWindow("imwindowclass", vbNullString)
If imwindowclass <> 0 Then
Call SendMessageLong(imwindowclass, WM_CLOSE, 0&, 0&)
GoTo 10
Else: Exit Function
End If
End Function
Do not use GoTo unless it's strictly necessary. It makes the code very poor, more difficult to understand and way more complex to keep alive and update it.
All programs can be coded without goto lines. For example:
code:
Public Function closeAll()
Dim imwindowclass As Long
imwindowclass = FindWindow("imwindowclass", vbNullString)
While imwindowclass <> 0
Call SendMessageLong(imwindowclass, WM_CLOSE, 0&, 0&)
imwindowclass = FindWindow("imwindowclass", vbNullString)
Wend
End Function
and if you don't like the 2 FindWindow calls (why not?), use a Do While True .... Loop and put an If imwindowclass = 0 Then Exit Do