Jump to content

Recommended Posts

Posted

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

Posted

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.

Posted (edited)

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!

Posted

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.

Posted (edited)

Oh God, you will hate me... I was modifying a copy of my script, then running the shortcut to my original...

StringIsInt works fine, thanks...

D'uh !

Sorry for that.

Edited by TheReveller

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
  • Recently Browsing   0 members

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