nightly count out?

flyboy1565

New member
Joined
Jun 3, 2010
Messages
2
Programming Experience
Beginner
creating a program to do nightly count out. having trouble can someone help this beginner.

Dim pen, nic, dime, quat, ones, fives, tens, twenties, fifties, hundred As Integer
Const pennies As Decimal = 0.01
pen = Val(tbp.Text) * Val(pennies)
nic = Val(tbn.Text)
dime = Val(tbd.Text)
quat = tbq.Text
ones = tb1.Text
fives = tb5.Text
tens = tb10.Text
twenties = tb20.Text
fifties = tb50.Text
hundred = tb100.Text
MessageBox.Show(pen)
MessageBox.Show(pennies)
MessageBox.Show(dime)

of course this is very bad i'm sure any help will do!

thanks
 
Private Sub btntotal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btntotal.Click
Dim pen, nic, dime, quat, ones, fives, tens, twenties, fifties, hundred As Integer
Const pennies As Decimal = 0.01
'Dim total As Object
'total = tbp + tbn + tbd
'lbltotal = Format(total, "$#,##0.00")
pen = CDec(tbp.Text) / 100
nic = CDec(tbn.Text) * 0.05
dime = CDec(tbd.Text) / 10
quat = CDec(tbq.Text) / 4
ones = CDec(tb1.Text)
fives = CDec(tb5.Text)
tens = CDec(tb10.Text)
twenties = CDec(tb20.Text)
fifties = CDec(tb50.Text)
hundred = CDec(tb100.Text)
MessageBox.Show(pen)
MessageBox.Show(nic)
MessageBox.Show(dime)
MessageBox.Show(quat)
 
Are you having trouble with conversions? You might try the Convert class and String.Format.
 
First of all, place Option Strict On at the very top of your program code. This will enforce explicit type conversion.

Do not use the legacy Val() function. It will convert the text to a type Double, and you are using Integers.

Do use the TryParse() method for converting user inputs from text in the textboxes into the required integer values. For example:
Integer.TryParse(Textbox1.Text, number)

To display the converted value results, use the ToString() method.
 
Back
Top