472,982 Members | 1,770 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,982 software developers and data experts.

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 3785
* =?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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Krish | last post by:
Hi, How to convert "1283912839E-5" string (in scientific format) to a decimal. Convert.ToDecimal("1283912839E-5") is throwing "Input string is not in correct format" exception. Is the...
4
by: aevans1108 | last post by:
expanding this message to microsoft.public.dotnet.xml Greetings Please direct me to the right group if this is an inappropriate place to post this question. Thanks. I want to format a...
2
by: KB | last post by:
Hi guys, In my DataGrid I have a column that displays decimal values as currency ( I set the Data Formatting expression of that column to {0:C}). So the actual string displayed in the grid looks...
3
by: JenHu | last post by:
Hi all, I have to read from a text file and generate values and insert to database. But first of all, when the text file contains '0000000000', I received a sEfundAmt value = 0D instead of 0.0...
7
by: patang | last post by:
I want to convert amount to words. Is there any funciton available? Example: $230.30 Two Hundred Thirty Dollars and 30/100
6
by: patang | last post by:
Could someone please tell me where am I supposed to put this code. Actually my project has two forms. I created a new module and have put the following code sent by someone. All the function...
7
by: elliotng.ee | last post by:
I have a text file that contains a header 32-bit binary. For example, the text file could be: %%This is the input text %%test.txt Date: Tue Dec 26 14:03:35 2006...
6
by: Mark Chimes | last post by:
Hi All, I need to search thru some strings and discard them if they canot be converted to a decimal or interger value. What is the best way to do this? cheers, Mark Chimes
19
by: VK | last post by:
http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/ b495b4898808fde0> is more than one month old - this may pose problem for posting over some news servers. This is why I'm...
10
by: cmdolcet69 | last post by:
Public ArrList As New ArrayList Public bitvalue As Byte() Public Sub addvalues() Dim index As Integer ArrList.Add(100) ArrList.Add(200) ArrList.Add(300) ArrList.Add(400) ArrList.Add(500)
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.