Jump to content

Abs returned value ?


Recommended Posts

Hello,

I have this in my code :

$input = InputBox("Graphique", "Entrez le nombre de chiffres retenus après la virgule en X", $decx, Default, 310, 140); Decimal places for X
$cancel = @error
If Not $cancel And StringIsDigit(Abs($input)) Then
    $decx = $input
EndIf
If Not StringIsDigit(Abs($input)) And Not $cancel Then
    MsgBox(16, "Graphique", "Veuillez entrer un nombre valide")
EndIf

I want to valid a number, it can be negative but not floating.

If I enter "4r4" the number is valid as if Abs("4r4") would return 4... But then I use that $decx = $input in a Round([...], $decx) and still it seems like Round([...],"4r4") works like Round([...],4).

I tried with StringIsInt but if I write "aasdf" in the inputbox, it still works...

Thanks

Link to comment
Share on other sites

But I write this :

$input = InputBox("Graphique", "Entrez le nombre de chiffres retenus après la virgule en X", $decx, Default, 310, 140); Decimal places for X

$cancel = @error

If Not $cancel And StringIsInt($input) Then

$decx = $input

EndIf

If Not StringIsInt($input) And Not $cancel Then

MsgBox(16, "Graphique", "Veuillez entrer un nombre valide")

EndIf

If I write "2a" or "2+2" or "a2a", the value is valid and it shouldn't.

Link to comment
Share on other sites

strange. StringIsInt give true only if the number is in the form -123 or 123. No decimal point or anything else. :D

Not very strange at all. StringIsInt is short for StringIsInteger, and 123.2 sure is not an integer.

Instead do: If StringIsInt() Or StringIsFloat() Then...

Edited by monoceres

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

I don't want floating numbers.

I want only numbers as these :

-526

-102

0

-0

8745

52

And not :

a6

6a

6.2

-0.1

-2.5

1+1

+1

I use "If StringIsInt() Or StringIsFloat()" when I want only numbers from -100000000.00 to 100000000.00 but now I don't want decimal.

Thanks.

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...