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!

Clearing Numeric Text Box

Status
Not open for further replies.

Auguy

Programmer
May 1, 2004
1,206
US
I have a textbox bound to a numeric field in a table coming from an SQL file. The problem I have is that when I hi-light the entire field and press the delete key and tab off the current control, the value reverts back to the hi-lighted text. If the hi-lighting does not include all of the text, everything works just fine. This doesn't happen with text fields. After searching the Net for some ideas, I added the following validating handler to the textbox to get around this. Why is this necessary? Is there a better way to handle this? Am I doing something wrong? Is this because the numeric field has to have a value even if it's zero and won't accept the blank text?
Code:
If txtMiles.Text.Trim.Length = 0 then
  txtMiles.Text = "0"
End If


Auguy
Sylvania, Ohio
 
Does the field in the table allow for null fields, if not deleting the text in the box would create an error, thus would change back to the hilighted form.
 
Yes it does.

Auguy
Sylvania, Ohio
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top