Try
System.Globalization.NumberFormatInfo nfi = new
System.Globalization.NumberFormatInfo();
nfi.NumberGroupSeparator = ",";
string s = "14.95";
decimal value = decimal.Parse(s, nfi);
--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"Ricky Lee" <(E-Mail Removed)> wrote in message
news:422528df$0$49370$(E-Mail Removed)...
> Does your system use the . (dot) symbol as the decimal symbol? Some
> european
> country use the comma (,) as decimal symbol, and dot (.) as the digit
> grouping symbol. If you're in the latter case, the conversion will ignore
> the dot and treat the "14.95" as "1495". You can solve this by using
> specific CultureInfo object to specify the locale that you want to use.
>
> Hope it helps.
>
> -- Ricky Lee
> ============================================
> ^o^ "When all doors are closed, God will open a Windows" ^o^
> ============================================
>
> "BA" <(E-Mail Removed)> wrote in message
> news:1109726232.92275607742901ff95e2563b42b197c8@teranews...
>>
>> "Peter Mancini" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > Show us the code. Copy it from your program. Might be a syntax issue.
>> >
>>
>> Thanks for the response, here is the code (cutout try catch for ease of
>> reading, other funciton just returns the decimal:
>>
>>
>> >>>>>>>>>>>>>>>code>>>>>>>>>>>>>>>>
>>
>> public decimal Lookup(string ISBN)
>> {
>> string CleanPrice;
>> decimal decCleanPrice;
>>
>>
> System.Diagnostics.Trace.WriteLine("AmazonWebServiceDLL:AmazonLookupAdapter
>> ENTER");
>>
>> //Create Instance of Proxy Class
>> SService as1 = new SService ();
>>
>> SService.lookup = ISBN;
>>
>> CleanPrice = as1.AsinSearchRequest(asin);
>>
>> CleanPrice =
>>
> System.Text.RegularExpressions.Regex.Replace(pi.Details[0].OurPrice,System.T
> ext.RegularExpressions.Regex.Escape("$"),
>> "");
>> System.Diagnostics.Trace.WriteLine("price: " + CleanPrice);
>>
>> decCleanPrice = ConvertStringDecimal(CleanPrice.ToString());
>>
>>
> System.Diagnostics.Trace.WriteLine(System.Convert.ToString(decCleanPrice));
>> System.Diagnostics.Trace.WriteLine("EXIT");
>>
>> return decCleanPrice;
>> }
>>
>>
>>
>> internal decimal ConvertStringDecimal(string stringVal)
>> {
>> decimal decimalVal;
>>
>> try
>> {
>> decimalVal = System.Convert.ToDecimal(stringVal);
>> System.Diagnostics.Trace.WriteLine("The string as a decimal is {0}.",
>> decimalVal.ToString());
>> return decimalVal;
>>
>> }
>> catch (System.OverflowException)
>> {
>> System.Diagnostics.Trace.WriteLine("The conversion from string to
>> decimal overflowed.");
>> return 0;
>> }
>> catch (System.FormatException)
>> {
>> System.Diagnostics.Trace.WriteLine("The string is not formatted as a
>> decimal.");
>> return 0;
>> }
>> catch (System.ArgumentNullException)
>> {
>> System.Diagnostics.Trace.WriteLine("The string is null.");
>> return 0;
>> }
>> }
>>
>> }
>> }
>>
>> >>>>>>>>>>>>>>>code>>>>>>>>>>>>>>>>
>>
>> Thanks again
>>
>>
>
>
|