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)

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)```

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

Share on other sites

i said i knew how to fix

but there is still 1 problem

if i'm using floating numbers int(string) won't work

any suggestions

but its funny to look at, have you tried it out?

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)```

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

Share on other sites

hey, thx thats great

why haven't i found this 1?

damn

can some1 maybe move this to v3support (now we all know its not a bug)

Create an account

Register a new account