Why bother converting to Decimal when you want a long ?
>That was an interesting question indeed. Apparently we do send tnScanNo with characters. In my code I just moved TRY before the first line.
>
>>Why would you expect to convert "P1111" to decimal ?
>>Try:
public static long ToLong(this String tcString)
>> {
>> long result = 0;
>> long.TryParse(tcString, out result);
>> return result;
>> }
>>
>>
>>
>>>I am now getting this error
>>>
>>>System.FormatException: Input string was not in a correct format.
>>> at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
>>> at System.Number.ParseDecimal(String value, NumberStyles options, NumberFormatInfo numfmt)
>>> at System.Convert.ToDecimal(String value, IFormatProvider provider)
>>>
>>>
>>>at this line of code
>>>
>>>
>>> //=====================================================================================================================
>>> public static long ToLong(this String tcString)
>>> {
>>> Decimal dDecimalValue = Convert.ToDecimal(tcString, CultureInfo.InvariantCulture);
>>> try { return (Int64)dDecimalValue; }
>>> catch { }
>>> return 0L;
>>> }
>>>