468,512 Members | 1,408 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,512 developers. It's quick & easy.

Convert string to decimal

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

Nov 20 '05 #1
4 3644
* =?Utf-8?B?TGVvbi5LZW1w?= <an*******@discussions.microsoft.com> 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!
Nov 20 '05 #2
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
Nov 20 '05 #3
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
Nov 20 '05 #4
* =?Utf-8?B?TGVvbi5LZW1w?= <an*******@discussions.microsoft.com> 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!
Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by JenHu | last post: by
7 posts views Thread by patang | last post: by
6 posts views Thread by patang | last post: by
7 posts views Thread by elliotng.ee | last post: by
6 posts views Thread by Mark Chimes | last post: by
10 posts views Thread by cmdolcet69 | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.