473,545 Members | 2,095 Online
Bytes | Software Development & Data Engineering Community
+ 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(B yVal sender As System.Object, _
ByVal e As System.EventArg s) 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(lblTot al.Text)) +
CDec(Val(txtCoi nsInArray(a).Te xt))
Next
If chkUncleSam.Che cked = True Then
lblTax.Text = CDec(Val(lblTot al.Text)) * Tax
End If
lblGross.Text = CDec(Val(lblTot al.Text)) - CDec(Val(lblTax .Text))
lblSplit.Text = CDec(Val(lblGro ss.Text)) \ 2
End Sub
End Class
</code>
--
Adam S
Jul 21 '05 #1
6 3180
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********@dis cussions.micros oft.com> a écrit dans le message
de news:45******** *************** ***********@mic rosoft.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(B yVal sender As System.Object, _
ByVal e As System.EventArg s) 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(lblTot al.Text)) +
CDec(Val(txtCoi nsInArray(a).Te xt))
Next
If chkUncleSam.Che cked = True Then
lblTax.Text = CDec(Val(lblTot al.Text)) * Tax
End If
lblGross.Text = CDec(Val(lblTot al.Text)) - CDec(Val(lblTax .Text))
lblSplit.Text = CDec(Val(lblGro ss.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********@dis cussions.micros oft.com> a écrit dans le message
de news:45******** *************** ***********@mic rosoft.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(B yVal sender As System.Object, _
ByVal e As System.EventArg s) 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(lblTot al.Text)) +
CDec(Val(txtCoi nsInArray(a).Te xt))
Next
If chkUncleSam.Che cked = True Then
lblTax.Text = CDec(Val(lblTot al.Text)) * Tax
End If
lblGross.Text = CDec(Val(lblTot al.Text)) - CDec(Val(lblTax .Text))
lblSplit.Text = CDec(Val(lblGro ss.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********@dis cussions.micros oft.com> a écrit dans le message
de news:45******** *************** ***********@mic rosoft.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(B yVal sender As System.Object, _
ByVal e As System.EventArg s) 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(lblTot al.Text)) +
CDec(Val(txtCoi nsInArray(a).Te xt))
Next
If chkUncleSam.Che cked = True Then
lblTax.Text = CDec(Val(lblTot al.Text)) * Tax
End If
lblGross.Text = CDec(Val(lblTot al.Text)) - CDec(Val(lblTax .Text))
lblSplit.Text = CDec(Val(lblGro ss.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********@dis cussions.micros oft.com> a écrit dans le message
de news:45******** *************** ***********@mic rosoft.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(B yVal sender As System.Object, _
ByVal e As System.EventArg s) 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(lblTot al.Text)) +
CDec(Val(txtCoi nsInArray(a).Te xt))
Next
If chkUncleSam.Che cked = True Then
lblTax.Text = CDec(Val(lblTot al.Text)) * Tax
End If
lblGross.Text = CDec(Val(lblTot al.Text)) - CDec(Val(lblTax .Text))
lblSplit.Text = CDec(Val(lblGro ss.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********@dis cussions.micros oft.com> a écrit dans le message
de news:D1******** *************** ***********@mic rosoft.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********@dis cussions.micros oft.com> a écrit dans le message de news:45******** *************** ***********@mic rosoft.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(B yVal sender As System.Object, _
> ByVal e As System.EventArg s) 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(lblTot al.Text)) +
> CDec(Val(txtCoi nsInArray(a).Te xt))
> Next
> If chkUncleSam.Che cked = True Then
> lblTax.Text = CDec(Val(lblTot al.Text)) * Tax
> End If
> lblGross.Text = CDec(Val(lblTot al.Text)) - CDec(Val(lblTax .Text)) > lblSplit.Text = CDec(Val(lblGro ss.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
3616
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; http://groups.google.com/group/comp.lang.python/browse_thread/thread/42150ccc20a1d8d5/4aadc71be8aeddbe#4aadc71be8aeddbe I copied this code and...
5
2376
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 correctly. I am trying to learn C# after playing around for a bit with procedural programming with PHP, not OOP, and believe I have learned quite a bit in...
11
4518
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 opinion of how I want to handle the 'user experience' in the application I'm creating. While I know I could allow the user to enter in number and alpha...
12
395
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 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...
7
1865
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 understand how to fix the problem. 'declaring variables Dim totalLiters As Double = Convert.ToDouble(txtLiters.Text) Dim totalPints As Double...
0
2407
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 checked for possible overflow exception, but did not encounter any. I have declared the values that i am trying to insert as DECIMAL data types in...
2
1732
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 a function to take two arguments:(a double number which may or may not be an integer, and an integer which will be the number of digits to store...
3
2491
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 import them back into the new table. well I tried that and get the same thing. is there a work around for the work around LOL
2
1440
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 four text boxes allowing a user to input (first name, last name, donation amount and date). After the user inputs the values, I want them to click...
0
7396
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7656
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7805
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7413
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7751
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
4943
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3449
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1874
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 we have to send another system
0
700
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.