need converting to and formating textbox values to decimal data ty

G

Guest

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>
 
G

Guest

Super Patrice, that was the problem. I will remeber this? "Lean right , to
get the money right!" silly little memory tool!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top