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 6 3171
\ 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
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
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
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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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;...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
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,...
|
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...
|
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...
|
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,...
|
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...
|
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...
|
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 ...
| |