Hi guys,

I'm trying to get my C# code translated into VB.NET but I'm facing troubles, so I turned to you guys.
Code is for re-positioning messagebox to desired location (not just center of screen) and code works fine in C#.

Here is original C# code in question:

Code:
 private void MoveMsgBox(int x, int y, bool repaint, string title)
        {
            Thread thr = new Thread(() => // New thread
            {
                IntPtr msgBox = IntPtr.Zero;
               
                while ((msgBox = FindWindow(IntPtr.Zero, title)) == IntPtr.Zero) ;

                Rectangle r = new Rectangle();
                GetWindowRect(msgBox, out r); 
                MoveWindow(msgBox 
                   r.Width - r.X 
                   r.Height - r.Y
                   repaint);
            });
            thr.Start();
        }

And my full- translated code in VB.NET:

Code:
<DllImport("user32.dll")>
    Private Shared Function FindWindow(ByVal classname As IntPtr, ByVal title As String) As IntPtr
    End Function

    <DllImport("user32.dll")>
    Private Shared Sub MoveWindow(ByVal hwnd As IntPtr, ByVal X As Integer, ByVal Y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal rePaint As Boolean)
    End Sub

    <DllImport("user32.dll")>
    Private Shared Function GetWindowRect(ByVal hwnd As IntPtr, <Out> ByRef rect As Rectangle) As Boolean
    End Function

  Private Sub MoveMsgBox(ByVal x As Integer, ByVal y As Integer, ByVal repaint As Boolean, ByVal title As String)
        Dim thr As Thread = New Thread(Sub()
                                           Dim msgBox As IntPtr = IntPtr.Zero

                                           While msgBox= FindWindow(IntPtr.Zero, title) = IntPtr.Zero
                                           End While

                                           Dim r As Rectangle = New Rectangle()
                                           GetWindowRect(msgBox, r)
                                           MoveWindow(msgBox, r.Width - r.X, r.Height - r.Y, repaint)
                                       End Sub)
        thr.Start()
    End Sub
There is no error in code, but "msgbox" allways returns 0 from FindWindow function. Any help kindly appreciated, thanks in advance.