my challenge is to create a program to calculate the cost for a particular customer according to how many dogs they have to be washed.
1 dog = $10.00
2 Dogs = $17.00
3 or more Dogs = $17.00 (price for 2 dogs) + $5 for each additional dog.
i therefore have written the following code:
its not layed out correctly since i havent had time to fix it yet..please try and read through!
VB Code:
Option Explicit Private Sub cmdamountfordwc_Click() txtamountfordwc.Text = Format(txtcalculatedprice.Text * Val(0.05), "$0.00") End Sub Private Sub txtenterdognumber__KeyPress(KeyAscii As Integer) If KeyAscii < 48 Or KeyAscii > 57 Then Select Case KeyAscii Case 8 Case Else KeyAscii = 0 End Select End If End Sub Private Sub cmdCalculateCharge_Click() If txtenterdognumber.Text >= 1 Then txtcalculatedprice.Text = Format(Val(10), "$0.00") End If If txtenterdognumber.Text >= 2 Then txtcalculatedprice.Text = Format(Val(17) + ((txtenterdognumber.Text - Val(2)) * Val(5)), "$0.00") End If If txtenterdognumber.Text = 0 Then Beep MsgBox " PLEASE ENTER NUMBER OF DOGS ", vbExclamation txtcalculatedprice.Text = "0" txtamountfordwc.Text = "0" End If End Sub Private Sub cmdclear_Click() txtamountfordwc.Text = "" txtcalculatedprice.Text = "" txtenterdognumber.Text = "" End Sub Private Sub cmdcountall_Click() Call cmdCalculateCharge_Click Call cmdamountfordwc_Click End Sub Private Sub cmdexit_Click() End End Sub Private Sub txtcalculatedprice__KeyPress(KeyAscii As Integer) If KeyAscii < 48 Or KeyAscii > 57 Then Select Case KeyAscii Case 8 Case Else KeyAscii = 0 End Select End If End Sub Private Sub txtamountfordwc__KeyPress(KeyAscii As Integer) If KeyAscii < 48 Or KeyAscii > 57 Then Select Case KeyAscii Case 8 Case Else KeyAscii = 0 End Select End If End Sub Private Sub txtenterdognumber_Change() If KeyAscii < 48 Or KeyAscii > 57 Then Select Case KeyAscii Case 8 Case Else KeyAscii = 0 End Select End If End Sub
the problem is i have to stop it letting me enter letters into the box, or decimal points and multiple letters and to not let you type them in. as you can see i have tried to but it just doesnt want to work. what have i done wrong?




Reply With Quote