Trouble with textboxes losing focus in Visual Basic .net <p>Recently I got an assignment to make a very basic Sudoku-game in Visual Basic. To make this I am using Visual Studio Ultimate 2013 Update 4 with the .NET Framework. </p> <p>I have gotten to the point where I can check which one out of many textboxes has focus. With this also change the backgroundColor of the corresponding textbox. I have done this using this by using this method:</p> <p><code>Private Sub TextBox_GotFocus() Handles TextBox1.GotFocus, TextBox2.GotFocus, TextBox3.GotFocus Me.ActiveControl.BackColor = Color.Aquamarine End Sub </code></p> <p>To Color it back to white when any of the textboxes lost focus I used this:</p> <p><code>Private Sub TextBox_LostFocus() Handles TextBox1.LostFocus, TextBox2.LostFocus, TextBox3.LostFocus Me.ActiveControl.BackColor = Color.White End Sub </code></p> <p><strong>Now My Questions Are:</strong></p> <ol> <li>Why does the Application crash when I close it? And how do I fix this?</li> </ol> <p>(It Gives a NullReferenceException when being closed)</p> <ol start="2"> <li>Is this even a proper way to accomplish what I want? Or is there something more efficient?</li> </ol>