473,385 Members | 1,742 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

need converting to and formating textbox values to decimal data ty

I have been reading in help how I need to use decimal becuase currency does
not exist like I used in vb6.
I had a difficult time on google and msdn finding how or if I can take the
value of text box as decimal or do I just have to make another decimal
variable
.. So I took a guess hoping CDec would come up blue if I type it in with no
squigglies on the line. But is this actually converting it to decimal.

Next if so, I do not like the out put to the textboxes
Total: 100
Tax: 4.500 I need it formatted as 4.50
Gross: 95.5
Split: 48 This is not accurate, it is rounding, It should be of course
half of 95.5, 47.75

<code>
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnCalc.Click
'Button 1 Calculate
Const Tax As Decimal = 0.045
Dim a As Integer
For a = 1 To 5
lblTotal.Text = CDec(Val(lblTotal.Text)) +
CDec(Val(txtCoinsInArray(a).Text))
Next
If chkUncleSam.Checked = True Then
lblTax.Text = CDec(Val(lblTotal.Text)) * Tax
End If
lblGross.Text = CDec(Val(lblTotal.Text)) - CDec(Val(lblTax.Text))
lblSplit.Text = CDec(Val(lblGross.Text)) \ 2
End Sub
End Class
</code>
--
Adam S
Jul 21 '05 #1
6 3164
Newbee,

Net1.x uses Bankers Rounding and there are no alternatives

http://support.microsoft.com/default...b;en-us;196652

I hope this helps,

Cor
Jul 21 '05 #2
\ is the integer division ? What if you try / instead ?

Patrice

--

"Newbee Adam" <Ne********@discussions.microsoft.com> a écrit dans le message
de news:45**********************************@microsof t.com...
I have been reading in help how I need to use decimal becuase currency does not exist like I used in vb6.
I had a difficult time on google and msdn finding how or if I can take the value of text box as decimal or do I just have to make another decimal
variable
. So I took a guess hoping CDec would come up blue if I type it in with no
squigglies on the line. But is this actually converting it to decimal.

Next if so, I do not like the out put to the textboxes
Total: 100
Tax: 4.500 I need it formatted as 4.50
Gross: 95.5
Split: 48 This is not accurate, it is rounding, It should be of course
half of 95.5, 47.75

<code>
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnCalc.Click
'Button 1 Calculate
Const Tax As Decimal = 0.045
Dim a As Integer
For a = 1 To 5
lblTotal.Text = CDec(Val(lblTotal.Text)) +
CDec(Val(txtCoinsInArray(a).Text))
Next
If chkUncleSam.Checked = True Then
lblTax.Text = CDec(Val(lblTotal.Text)) * Tax
End If
lblGross.Text = CDec(Val(lblTotal.Text)) - CDec(Val(lblTax.Text))
lblSplit.Text = CDec(Val(lblGross.Text)) \ 2
End Sub
End Class
</code>
--
Adam S

Jul 21 '05 #3
Super Patrice, that was the problem. I will remeber this? "Lean right , to
get the money right!" silly little memory tool!
--
Adam S
"Patrice" wrote:
\ is the integer division ? What if you try / instead ?

Patrice

--

"Newbee Adam" <Ne********@discussions.microsoft.com> a écrit dans le message
de news:45**********************************@microsof t.com...
I have been reading in help how I need to use decimal becuase currency

does
not exist like I used in vb6.
I had a difficult time on google and msdn finding how or if I can take

the
value of text box as decimal or do I just have to make another decimal
variable
. So I took a guess hoping CDec would come up blue if I type it in with no
squigglies on the line. But is this actually converting it to decimal.

Next if so, I do not like the out put to the textboxes
Total: 100
Tax: 4.500 I need it formatted as 4.50
Gross: 95.5
Split: 48 This is not accurate, it is rounding, It should be of course
half of 95.5, 47.75

<code>
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnCalc.Click
'Button 1 Calculate
Const Tax As Decimal = 0.045
Dim a As Integer
For a = 1 To 5
lblTotal.Text = CDec(Val(lblTotal.Text)) +
CDec(Val(txtCoinsInArray(a).Text))
Next
If chkUncleSam.Checked = True Then
lblTax.Text = CDec(Val(lblTotal.Text)) * Tax
End If
lblGross.Text = CDec(Val(lblTotal.Text)) - CDec(Val(lblTax.Text))
lblSplit.Text = CDec(Val(lblGross.Text)) \ 2
End Sub
End Class
</code>
--
Adam S


Jul 21 '05 #4
is Cdec correct to convert decimal datatype, I could not find it in help?
--
Adam S
"Newbee Adam" wrote:
Super Patrice, that was the problem. I will remeber this? "Lean right , to
get the money right!" silly little memory tool!
--
Adam S
"Patrice" wrote:
\ is the integer division ? What if you try / instead ?

Patrice

--

"Newbee Adam" <Ne********@discussions.microsoft.com> a écrit dans le message
de news:45**********************************@microsof t.com...
I have been reading in help how I need to use decimal becuase currency

does
not exist like I used in vb6.
I had a difficult time on google and msdn finding how or if I can take

the
value of text box as decimal or do I just have to make another decimal
variable
. So I took a guess hoping CDec would come up blue if I type it in with no
squigglies on the line. But is this actually converting it to decimal.

Next if so, I do not like the out put to the textboxes
Total: 100
Tax: 4.500 I need it formatted as 4.50
Gross: 95.5
Split: 48 This is not accurate, it is rounding, It should be of course
half of 95.5, 47.75

<code>
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnCalc.Click
'Button 1 Calculate
Const Tax As Decimal = 0.045
Dim a As Integer
For a = 1 To 5
lblTotal.Text = CDec(Val(lblTotal.Text)) +
CDec(Val(txtCoinsInArray(a).Text))
Next
If chkUncleSam.Checked = True Then
lblTax.Text = CDec(Val(lblTotal.Text)) * Tax
End If
lblGross.Text = CDec(Val(lblTotal.Text)) - CDec(Val(lblTax.Text))
lblSplit.Text = CDec(Val(lblGross.Text)) \ 2
End Sub
End Class
</code>
--
Adam S


Jul 21 '05 #5
is Cdec correct for decimal. I search in help and could not find? I just
guess.
--
Adam S
"Patrice" wrote:
\ is the integer division ? What if you try / instead ?

Patrice

--

"Newbee Adam" <Ne********@discussions.microsoft.com> a écrit dans le message
de news:45**********************************@microsof t.com...
I have been reading in help how I need to use decimal becuase currency

does
not exist like I used in vb6.
I had a difficult time on google and msdn finding how or if I can take

the
value of text box as decimal or do I just have to make another decimal
variable
. So I took a guess hoping CDec would come up blue if I type it in with no
squigglies on the line. But is this actually converting it to decimal.

Next if so, I do not like the out put to the textboxes
Total: 100
Tax: 4.500 I need it formatted as 4.50
Gross: 95.5
Split: 48 This is not accurate, it is rounding, It should be of course
half of 95.5, 47.75

<code>
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnCalc.Click
'Button 1 Calculate
Const Tax As Decimal = 0.045
Dim a As Integer
For a = 1 To 5
lblTotal.Text = CDec(Val(lblTotal.Text)) +
CDec(Val(txtCoinsInArray(a).Text))
Next
If chkUncleSam.Checked = True Then
lblTax.Text = CDec(Val(lblTotal.Text)) * Tax
End If
lblGross.Text = CDec(Val(lblTotal.Text)) - CDec(Val(lblTax.Text))
lblSplit.Text = CDec(Val(lblGross.Text)) \ 2
End Sub
End Class
</code>
--
Adam S


Jul 21 '05 #6
This is part of the VB.NET language (i.e. you'll find in the VB.NET language
specification not in the framework class library doc) :
http://msdn.microsoft.com/library/de...Conversion.asp

--
Patrice
"Newbee Adam" <Ne********@discussions.microsoft.com> a écrit dans le message
de news:D1**********************************@microsof t.com...
is Cdec correct to convert decimal datatype, I could not find it in help?
--
Adam S
"Newbee Adam" wrote:
Super Patrice, that was the problem. I will remeber this? "Lean right , to get the money right!" silly little memory tool!
--
Adam S
"Patrice" wrote:
\ is the integer division ? What if you try / instead ?

Patrice

--

"Newbee Adam" <Ne********@discussions.microsoft.com> a écrit dans le message de news:45**********************************@microsof t.com...
> I have been reading in help how I need to use decimal becuase currency does
> not exist like I used in vb6.
> I had a difficult time on google and msdn finding how or if I can take the
> value of text box as decimal or do I just have to make another decimal > variable
> . So I took a guess hoping CDec would come up blue if I type it in with no > squigglies on the line. But is this actually converting it to decimal. >
> Next if so, I do not like the out put to the textboxes
> Total: 100
> Tax: 4.500 I need it formatted as 4.50
> Gross: 95.5
> Split: 48 This is not accurate, it is rounding, It should be of course > half of 95.5, 47.75
>
> <code>
> Private Sub Button1_Click(ByVal sender As System.Object, _
> ByVal e As System.EventArgs) Handles btnCalc.Click
> 'Button 1 Calculate
> Const Tax As Decimal = 0.045
> Dim a As Integer
> For a = 1 To 5
> lblTotal.Text = CDec(Val(lblTotal.Text)) +
> CDec(Val(txtCoinsInArray(a).Text))
> Next
> If chkUncleSam.Checked = True Then
> lblTax.Text = CDec(Val(lblTotal.Text)) * Tax
> End If
> lblGross.Text = CDec(Val(lblTotal.Text)) - CDec(Val(lblTax.Text)) > lblSplit.Text = CDec(Val(lblGross.Text)) \ 2
> End Sub
> End Class
> </code>
> --
> Adam S

Jul 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: geskerrett | last post by:
In the '80's, Microsoft had a proprietary binary structure to handle floating point numbers, In a previous thread, Bengt Richter posted some example code in how to convert these to python floats;...
5
by: MFC | last post by:
Ok, after three C# books, (C# How to Program, Programming in the Key of C#, and C# Weekend Crash Course) and three weeks, I believe I have tried everything to make a certain form function...
11
by: Keith | last post by:
I apologize for those of you who think I'm posting on the same topic. It is not that I don't appreciate all of your comments - and I'm definitely reading them all - but I think I have a differing...
12
by: Newbee Adam | last post by:
I have been reading in help how I need to use decimal becuase currency does not exist like I used in vb6. I had a difficult time on google and msdn finding how or if I can take the value of text...
7
by: Charlie Brookhart | last post by:
I have a program (posted below) that is supposed to take liters, which is the user input, and convert it to pints and gallons. The pints and gallons are displayed in a read only textbox. I don't...
0
by: rajmgopal | last post by:
Hello Everyone I am getting the following error when i try to insert a record into Sql Server 2005 from my VB 2005 application. sqlEx = {"Error converting data type numeric to numeric."} I...
2
by: sitko | last post by:
Hi, I'm in the process of converting a VB.net program into a C program so it can run on a unix like machine. I've been moving along at a nice pace, but this conversion has stumped me. I need...
3
by: sparks | last post by:
After changing all the variables in a table from long to double. you get 9.1====becomes==== 9.19999980926514 ok I checked microsoft and they had a workaround. export the values to excel...then...
2
by: mturner64 | last post by:
Good Day! I am fairly new to asp.net. I am using Microsoft VWD 2008 express edition. I have linked an Access 2007 database to my asp.net application using a gridview control. On the webpage are...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.