Well basically i want to know how i can write an IF...THEN decision structure based on the contents of a textbox.
for example lets say i want to say something like
IF textbox1.text (has no text in the field) THEN textbox1.text = 0
Also how do i write a code that only allows integers of a positive value to be typed and accepted into the textbox

how do i....textbox?
AnOracle
Robin Moss
e is a property passed in to the key pressed event, it's of type keypressedeventargs. You may have called it something different, such as ea.
az1538
// IF textbox1.text (has no text in the field) THEN textbox1.text = 0
You want to text to equal "0" You should put it in quotes. VB, being weakly typed, will do this for you, but it's better to say what you mean :-)
if string.isnullorempty(textbox1.text) then textbox1.text = "0"
The Leave event is the most logical place to be doing this sort of stuff ( in other words, when the textbox loses focus )
as for the second question - the maskedtextbox is one way you can do this, the other is to handle one of the key events of the textbox, and use char.iscontrol and char.isdigit to set e.handled in that event handler ( e being the event passed in ). If Handled is true, then the key is rejected. I prefer to roll my own, I don't like the way the maskedtextbox works. It may, however, be an easier solution to your problem if you're happy with the way it does it's stuff.
antoan
Private
Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress If Char.IsNumber(e.KeyChar) Then