473,467 Members | 1,590 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 3171
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.