Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem validation

Status
Not open for further replies.

tigerlilly

Technical User
Joined
Mar 30, 2004
Messages
7
Location
US
What is the code to validate a text field that is required and is greater than 0. Also if Price is subtracted from down payment I have the validate the down payment field so that it is less than the price.
 
Often I find the answer to "Do I have to" questions are best answered with a "What if I don't."

Wil Mead
wmead@optonline.net

 
Hi,
Private Sub txtPrice_LostFocus()
If (IsNumeric(txtPrice.Text)) = True Then 'checks for valid data
If Val(txtPrice.Text) > 0 Then
dblPrice = Val(txtPrice.Text)
Else
MsgBox "Sorry, Price Value Must be Greater Than Zero"
txtPrice.Text = ""
txtPrice.SetFocus
End If
Else
MsgBox "Sorry, Invalid Data Entered",
txtPrice.Text = ""
txtPrice.SetFocus
End If
End Sub

Private Sub txtDpaymt_LostFocus()
If (IsNumeric(txtDpaymt.Text)) = True Then 'checks for valid data
If Val(txtDpaymt.Text) <= dblPrice Then
dblDpaymt = Val(txtDpaymt.Text)
Else
MsgBox &quot;Sorry, Downpayment is Greater Than Price&quot;
txtDpaymt.Text = &quot;&quot;
txtDpaymt.SetFocus
End If
Else
MsgBox &quot;Sorry, Invalid Data Entered&quot;,
txtDpaymt.Text = &quot;&quot;
txtDpaymt.SetFocus
End If
End Sub

Jon

 
1. If textfield <> &quot;&quot; Then
'something
End If

2 If downpayment < Price The
Price = Price - downpayment
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top