Jump to content

Recommended Posts

Posted (edited)

I'm sure this is a simple fix and I feel really dumb for posting this <.< but after messing around with it for 20min I can't seem to get it to work. :)

GUICreate("Enter User & Pass",230,90)
GUICtrlCreateLabel("Username:",15,5)
$User=GUICtrlCreateInput("",70,0,100,20)
GUICtrlCreateLabel("Password:",16,35)
$Pass=GUICtrlCreateInput("",70,32,100,20)
GUICtrlCreateLabel("Password:",16,65)
$Pass2=GUICtrlCreateInput("",70,62,100,20)
$DoneButton=GUICtrlCreateButton("Done",180,33)
GUISetState()

While 1
$msg = GUIGetMsg()
If $msg = -3 Then ExitLoop
If $msg = $DoneButton Then 
$Username=GUICtrlRead($User)
$Password=GUICtrlRead($Pass)
$Password2=GUICtrlRead($Pass2)

If Not $Password = $Password2 Then
MsgBox(0,"Mismatch","The passwords do not match")
EndIf
EndIf
Wend

for the some reason the above code won't work, if I take out the "Not" then the message box goes off. so $Password does = $Password2

Username: a

Password: b

Password: b

Edited by will88
Posted

GUICreate("Enter User & Pass", 230, 90)
GUICtrlCreateLabel("Username:", 15, 5)
$User = GUICtrlCreateInput("", 70, 0, 100, 20)
GUICtrlCreateLabel("Password:", 16, 35)
$Pass = GUICtrlCreateInput("", 70, 32, 100, 20)
GUICtrlCreateLabel("Password:", 16, 65)
$Pass2 = GUICtrlCreateInput("", 70, 62, 100, 20)
$DoneButton = GUICtrlCreateButton("Done", 180, 33)
GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = -3 Then ExitLoop
    If $msg = $DoneButton Then
        
        $Username = GUICtrlRead($User)
        $Password = GUICtrlRead($Pass)
        $Password2 = GUICtrlRead($Pass2)

        If $Password <> $Password2 Then
            MsgBox(0, "Mismatch", "The passwords do not match")
        Else
            MsgBox(0, "Match", "The passwords do match")
        EndIf
    EndIf
WEnd

Posted (edited)

Understand the difference with your code and where yours went wrong?

Not really I've never seen the IF with ( ) in autoit and I tried == instead of = before but that didn't work ethier.

Edited by will88
  • Developers
Posted (edited)

Its simple ones you understand:

This

If Not $Password = $Password2 Then

Is resolved from left to right... thus first step is to resolve "Not $Password"

This will resolve to False.

After that you compare "False = $password2"

so your statement is resolved like coding it as:

If (Not $Password) = $Password2 Then

The == just makes it compare Case-sensitive which is something you want for passwords.

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...