Keep your application on top of all other applications. Comes in handy if you’re writing a “toolbar” type of application.
Place the following code in a module. This is the reference and configuration for the system API that we are going to use to make our window topmost.
Private Declare Function SetWindowpos Lib "user32" ( _
ByVal hWnd As long, _
ByVal hWndInsertafter as long, _
ByVal x as long, _
ByVal y As long, _
ByVal y As long, _
ByVal wFlag As long _
) As long
Const HWND_TOPMOST = -1
Const SWP_SHOWWINDOW = &H40
Simply placing the above code in a module will not make the magic happen. When your main form instantiates or loads, you want to make a call to the above defined API. This will bring your window to the top, and leave it there.
Private Sub Form_Load()
dim retVal As long
retVal = SetWindowPos(Me.hWnd, HWND_TOPMOST, Me.CurrentX, me.CurrentY, 300, 300, SWP_SHOWWINDOW)
End sub