Jump to content
Sign in to follow this  
k1die

Can't understand why

Recommended Posts

k1die

Ok i have a little problem, i made this:

$vot = 0 
$x = inputbox("aaa" , "bbb")
$y = InputBox("aaa" , "bbb")
$z = abs($x - $y)
Select
Case($x < $y)
        $vot = $x
Case Else   
    $vot = $y
EndSelect
msgbox(0,"aaa","x=" & $x & "y=" & $y & "z=" & $z & "vot=" & $vot).

I need the lower value between xy, and the difference between them. The script works with some numbers but with other numbers not. I would be so glad if i found out why :)

examples:

$x = 1000

$y = 4000

it tells me that $vot = 1000 which is correct

but if i insert

$x = 104

$y = 24

it tells me that $vot = 104 :|

Share this post


Link to post
Share on other sites
smartee

Just out of curiousity why did you make three threads?

Share this post


Link to post
Share on other sites
smartee

try this:

$phrases = StringSplit("less than|greater than|equal to", "|", 2)
$phrase = $phrases[0]

$x = InputBox(@ScriptName, "Enter number x")
$y = InputBox(@ScriptName, "Enter number y")

$diff = $y - $x
If ($y < $x) Then
    $phrase = $phrases[1]
    $diff = $x - $y
ElseIf ($y = $x) Then
    $phrase = $phrases[2]
EndIf

MsgBox(64, @ScriptName, "x(" & $x & ") is " & $phrase & " y(" & $y & "). Difference is " & $diff)
Edit: Wow, the 104,24 data screws this up too, hmm, what am i doing wrong..

Edited by smartee

Share this post


Link to post
Share on other sites
andrei0x309

Cause the interpreter dose not know that x and y are numbers .

$vot = 0
$x = Number(inputbox("aaa" , "bbb"))
$y = Number(InputBox("aaa" , "bbb"))
$z = abs($x - $y)
Select
Case($x < $y)
        $vot = $x
Case Else
    $vot = $y
EndSelect
msgbox(0,"aaa","x=" & $x & "y=" & $y & "z=" & $z & "vot=" & $vot)

Share this post


Link to post
Share on other sites
smartee
:unsure: how did i miss that :> you are absolutely right.

Share this post


Link to post
Share on other sites
k1die

Cause the interpreter dose not know that x and y are numbers .

You gave me a brilliant idea :unsure:, i added $x+0 < $y+0 and it works just fine.

Thanks all for reply, i`ll go back to work :>, newbie doing stuff... take cover something might blow up

Sry for triple posting, really tired screwed up a bit.

Share this post


Link to post
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
Sign in to follow this  

×