PC Review


Reply
Thread Tools Rate Thread

Convert string to decimal

 
 
=?Utf-8?B?TGVvbi5LZW1w?=
Guest
Posts: n/a
 
      27th Feb 2004
In previous versions of VB, changing a string of numerals to a number was easy. Val and convert.todecimal both change 32.75 to 32. What should I be doing here

Thank

Leo

 
Reply With Quote
 
 
 
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      28th Feb 2004
* =?Utf-8?B?TGVvbi5LZW1w?= <(E-Mail Removed)> scripsit:
> In previous versions of VB, changing a string of numerals to a number
> was easy. Val and convert.todecimal both change 32.75 to 32. What
> should I be doing here?


There was never a 'Convert.ToDecimal' in VB6. Maybe you are looking for
'Double.Parse'?

--
Herfried K. Wagner [MVP]
<http://dotnet.mvps.org/>
Website Address Changed!
 
Reply With Quote
 
=?Utf-8?B?TGVvbi5LZW1w?=
Guest
Posts: n/a
 
      28th Feb 2004
Sorry, Herfried, should have been more specific.

What I meant was that in VB6 there was no issue

In .Net, I have tried Convert.ToDecimal and Val to convert a text value to Decimal, rior to writing to anAccess database. Both of these give me a truncated value of 32 for an original value of 32.75

(What a difference a line return makes!

Thank
Leon Kemp
 
Reply With Quote
 
=?Utf-8?B?TGVvbi5LZW1w?=
Guest
Posts: n/a
 
      28th Feb 2004
Herfried

Ooops. Further checking ( including another variable whose value I can check) shows that both convert and val are working fine. The problem arises when I am trying to transfer the value to Access. The column in Access is set to expect a decimal value, 2 decimal places accuracy, but for some reason _Access_ is truncating it to Integer

Any thoughts

Leon
 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      28th Feb 2004
* =?Utf-8?B?TGVvbi5LZW1w?= <(E-Mail Removed)> scripsit:
> What I meant was that in VB6 there was no issue.
>
> In .Net, I have tried Convert.ToDecimal and Val to convert a text
> value to Decimal, rior to writing to anAccess database. Both of these
> give me a truncated value of 32 for an original value of 32.75.


Notice that some functions are not locale-aware, so using a comma
character different from the system's comma character will cause wrong
results.

--
Herfried K. Wagner [MVP]
<http://dotnet.mvps.org/>
Website Address Changed!
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert Ascii string to decimal friend Microsoft VB .NET 8 30th Apr 2009 12:34 PM
Simple Convert String to Decimal with 2 places to the right. pvong Microsoft ASP .NET 2 3rd Oct 2007 11:41 AM
Convert C# string to decimal STom Microsoft C# .NET 4 14th Jan 2005 05:22 PM
How to convert string to decimal? JenHu Microsoft ASP .NET 3 6th Jan 2005 05:33 PM
How to convert decimal to string ? Anders Both Microsoft C# .NET 2 8th Jan 2004 02:43 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:16 AM.