What's wrong with my formula?

Hi there!

I’m just wondering why this formula doesn’t work properly. My app is on the web.

I’m trying to make sure that the last four digits of my ItemNumber field are numeric.

@TextToNumber(@Right(ItemNumber;4))

This function throws an error if ItemNumber equals DINPR25, but doesn’t throw an error if ItemNumber equals DIN25PR. Shouldn’t the formula throw an error or am I missing something?

Puzzled!

Subject: What’s wrong with my formula?

From the help:

Syntax

@TextToNumber( string )

Parameters

string

Text. The string you want to convert to a number. If the string contains both numbers and letters, it must begin with a number to be converted properly. For example, the string “12ABC” converts to 12, but “ABC12” produces an error.

Return value

number

Number. The string, converted to a number.

Subject: A better method might be using: @Matches(@Right(ItemNumber; 4); “+{0-9}”)

Subject: What’s wrong with my formula?

@TextToNumber drops all numbers to the right of the number as stated in the Designer Help: "If the string contains both numbers and letters, it must begin with a number to be converted properly. For example, the string “12ABC” converts to 12, but “ABC12” produces an error."Better use @IsNumber as in:

@If(@IsNumber(FieldName);“OK”;“NotOK”)

Regards,

Don

Subject: RE: What’s wrong with my formula?

As he wants to check only to four last digit,I would use the formula below instead of yours.

@IsNumber(@Right(ItemNumber;4))

Renaud

Subject: RE: What’s wrong with my formula?

Good point !