Hey e1,

I went out of the way to make my project fool-proof. U can c the pic below, I have 2 input textboxes and 1 output text box. Im trying to get my code to where if you enter a Character i.e. "abc" , then A mSGBox will tell you to enter a valid income amount. The problem Im having is if you enter ne value and/or character, you get a msgbox ne wayz. I would appreciate the help. Peace (files are attached)

[IMG]http://www.geocities.com/rc_og/incometax.jpg[/IMG]

Recommended Answers

All 6 Replies

The Zip is Invalid or corrupt... Please reattach the .zip in a new post to this thread. Thanks.

The Zip is Invalid or corrupt... Please reattach the .zip in a new post to this thread. Thanks.

Here u go............

You need error-trapping for your textboxes, for instance:

If Not IsNumeric(Text1.Text) or Not IsNumeric(Text2.Text) Then
MsgBox ("Invalid Entry")
Exit Sub
End If

rejects non-numeric entries or no entry

or:
If Text1.Text < 10 or Text1.Text > 1000 Then
MsgBox("Entry must be between 10 and 1000")
Text1.Text = ""
Text1.SetFocus
Exit Sub
End If

You have to think of every error a user might make, and trap it.

Private Sub cmdCompute_Click()
Dim intNumExemptions As Integer, curIncome As Currency

If lblexemptions.Caption = "" Then
MsgBox "Please enter Exemption", vbExclamation + vbOKOnly, "Enter Tax Exemptions"
Exit Sub
End If

intNumExemptions = CInt(lblexemptions.Caption)
If intNumExemptions <= -1 Then
MsgBox "Please enter Exmption", vbExclamation + vbOKOnly, "Enter Tax Exemptions"
Exit Sub
End If

curIncome = CCur(txtincome.Text)
If curIncome <= 0 Then
MsgBox "Please Enter a Valid Income", vbExclamation + vbOKOnly, "Enter Valid Income"
Exit Sub
End If

txttaxes.Text = Format(curComputeTaxes(intNumExemptions, curIncome), "currency")
End Sub

Compare this with the original code: You were checking the value of the variables before you had assigned a value to them, so they were still 0.

thanks to all, im about 2 check this out.....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.