 <p>You're declaring on the <code>attempt</code> varible inside the <code>Login_Click</code> event handler. Hence, each time the <code>Login_Click</code> event is raised, you are initializing it to 0.</p> <pre><code>Dim attempt As Integer = 0 </code></pre> <p>Try to move it to outer scope, for example make it a member of the Class.</p>