Jump to content

comparing inputbox values ?bug?


Recommended Posts

ok, i just discovered a little problem using inputboxes (i know its old-fashioned, but i wanted to make a simple program to compare 2 user input values {numbers only})

here's what i did:

$i1 = InputBox ("#1", "Please give a number", 10)
$i2 = InputBox ("#2", "Please give a number", 9)

if $i1 > $i2 Then
    $max = $i1
    $min = $i2
ElseIf $i1 = $i2 Then
    $max = $i1
    $min = $i1
elseif $i2 > $i1 Then
    $max = $i2
    $min = $i1
EndIf

msgbox (0, "Test", "Higher value: " & $max & @cr & "Lower value: " & $min)

i know how to fix it for me, but i just thought, that you might want to know (and see)

Link to comment
Share on other sites

currently your comparing strings cast it to int

$i1 = Int(InputBox ("#1", "Please give a number", 10))
$i2 = Int(InputBox ("#2", "Please give a number", 9))

if $i1 > $i2 Then
    $max = $i1
    $min = $i2
ElseIf $i1 = $i2 Then
    $max = $i1
    $min = $i1
elseif $i2 > $i1 Then
    $max = $i2
    $min = $i1
EndIf

msgbox (0, "Test", "Higher value: " & $max & @cr & "Lower value: " & $min)

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

$i1 = Number(InputBox ("#1", "Please give a number", 10))
$i2 = Number(InputBox ("#2", "Please give a number", 9))

if $i1 > $i2 Then
    $max = $i1
    $min = $i2
ElseIf $i1 = $i2 Then
    $max = $i1
    $min = $i1
elseif $i2 > $i1 Then
    $max = $i2
    $min = $i1
EndIf

msgbox (0, "Test", "Higher value: " & $max & @cr & "Lower value: " & $min)

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...