Post Reply 
VB.net help
Author Message
ZiNgA BuRgA
Smart Alternative

Posts: 17,022.2988
Threads: 1,174
Joined: 19th Jan 2007
Reputation: -1.71391
E-Pigs: 446.1274
Offline
Post: #17
RE: VB.net help
roberth Wrote:And where have i defined my attempt as 3 exactly??...i can't find it, and that's one of the major problems :(
Okay, umm, I'll try to explain it better:

Code:
Do
            lblAttempt.Text = "Enter password. This is attempt number " & Attempt
            Attempt = Attempt + 1
        Loop Until (Attempt = 4) Or (txtPass.Text = Password)

So, when you start the loop, Attempt =1.
First thing you do in the loop is set the attempt label to "1", then you add 1 to Attempt (so Attempt =2)

Then it will check the loop condition.  Since txtPass.Text is never changed within the loop, (txtPass.Text = Password) will _always_ be false.  So the condition can be broken down to Loop Until (Attempt = 4) Or False
You're "Or'ing" a False, which is equivalent to not "Or'ing" anything, so the above condition is equivalent to Loop Until (Attempt = 4).

Okay, so, since Attempt =2 at this point in time, the condition is False, and the loop continues.

On the next iteration of the loop, Attempt =3.

On the next iteration after that, when Attempt =3, the label is set to "3", Attempt is incremented (so Attempt now =4).  Then wee check the loop condition.  (Attempt = 4) is now true, so the loop exits.

So, the last value the label was set is "3".

This is because the loop isn't "delayed", that is, the computer sets the label to "1", "2" then "3", however, it does it so fast that you only see the final thing, a "3".

Hope that helps.

03/11/2007 04:50 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 


Messages In This Thread
VB.net help - roberth - 11/10/2007, 11:38 AM
RE: VB.net help - UncertainGod - 11/10/2007, 11:47 AM
RE: VB.net help - ZiNgA BuRgA - 11/10/2007, 08:00 PM
RE: VB.net help - roberth - 12/10/2007, 02:21 AM
RE: VB.net help - diego - 12/10/2007, 02:32 AM
RE: VB.net help - ZiNgA BuRgA - 12/10/2007, 03:25 AM
RE: VB.net help - roberth - 31/10/2007, 01:41 PM
RE: VB.net help - ZiNgA BuRgA - 31/10/2007, 06:43 PM
RE: VB.net help - |-Anubis-| - 31/10/2007, 06:46 PM
RE: VB.net help - ZiNgA BuRgA - 31/10/2007, 06:47 PM
RE: VB.net help - roberth - 01/11/2007, 04:22 AM
RE: VB.net help - roberth - 02/11/2007, 04:53 AM
RE: VB.net help - ZiNgA BuRgA - 02/11/2007, 07:07 AM
RE: VB.net help - roberth - 02/11/2007, 07:59 AM
RE: VB.net help - ZiNgA BuRgA - 02/11/2007, 07:04 PM
RE: VB.net help - roberth - 03/11/2007, 04:04 AM
RE: VB.net help - ZiNgA BuRgA - 03/11/2007 04:50 AM
RE: VB.net help - roberth - 03/11/2007, 05:00 AM
RE: VB.net help - ZiNgA BuRgA - 03/11/2007, 07:19 AM
RE: VB.net help - roberth - 04/11/2007, 05:36 AM
RE: VB.net help - ZiNgA BuRgA - 04/11/2007, 06:42 PM
RE: VB.net help - roberth - 10/12/2007, 03:06 AM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)

 Quick Theme: