I don't know what wrong with my code is?
When I start guessing, but it appeared "Must be in the Range of..." looping .
I don't know what the problem with my logic is ?
And this is the 1st ver. of this code...
It can be run normally..↓
When I start guessing, but it appeared "Must be in the Range of..." looping .
I don't know what the problem with my logic is ?
[ autoit ]
While 1 Local $setMax = InputBox("","Input Max Num:") Local $setMin = InputBox("","Input Min Num:") Local $MXtemp = $setMax Local $MNtemp = $setMin $RandomNum = Random($setMin, $setMax, 1) ;debug MsgBox(0, "", $RandomNum) Do $Guess = InputBox("","Guess Number:") If @error <> 1 Then If $Guess < $setMax And $Guess > $setMin Then If $Guess < $RandomNum Then $setMin = $Guess $MNtemp = $setMin MsgBox(0, "", "Too high..." & @CRLF & $setMin & "-" & $setMax) ElseIf $Guess > $RandomNum Then $setMax = $Guess $MXtemp = $setMax MsgBox(0, "", "Too low..." & @CRLF & $setMin & "-" & $setMax) Else MsgBox(0, "", "Excellent!" & @CRLF & "The Number is:" & $RandomNum) ExitLoop EndIf Else $setMax = $MXtemp $setMin = $MNtemp MsgBox(0, "", "Must be in the Range of" & @CRLF & $setMin & " and "& $setMax) EndIf Else ExitLoop EndIf Until $Guess == $RandomNum $again = MsgBox(1, "", "Continue?") If $again == 2 Then ExitLoop WEnd
And this is the 1st ver. of this code...
It can be run normally..↓
[ autoit ]
While 1 Dim $High = 100, $MXtemp = 100, $Low = 1, $MNtemp = 1 $RandomNum = Random(1, 100, 1) Do $Guess = InputBox("", "Guess Number:") If @error <> 1 Then If $Guess < $High And $Guess > $Low Then If $Guess < $RandomNum Then $Low = $Guess $MNtemp = $Low MsgBox(0, "", "Too low..." & @CRLF & $Low & "-" & $High) ElseIf $Guess > $RandomNum Then $High = $Guess $MXtemp = $High MsgBox(0, "", "Too high..." & @CRLF & $Low & "-" & $High) Else MsgBox(0, "", "Excellent!" & @CRLF & "The Number is:" & $RandomNum) ExitLoop EndIf Else $High = $MXtemp $Low = $MNtemp MsgBox(0, "", "Must be in the Range of" & @CRLF & $Low & " and " & $High) EndIf Else ExitLoop EndIf Until $Guess == $RandomNum $again = MsgBox(1, "", "Continue?") If $again == 2 Then ExitLoop WEnd