Convert string to decimal

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
* =?Utf-8?B?TGVvbi5LZW1w?= said:
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'?
 
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
 
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
 
* =?Utf-8?B?TGVvbi5LZW1w?= said:
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.
 
Back
Top