I have a program that allows the user to enter data I am using if statements that only will allow the user to enter integers and numbers if its greater than other and that works fine if the number or value is incorrect then a msg box appears. I have it so that if the number is wrong it takes the invalid number out of the test box.. I need to have it so that the user can enter the values over and over again. so the text boxes need to be cleared after the enter button is clicked. I have it now so that every time enter is clicked it clears the txt boxes but i only want them emptied once all the values are correct. I dont know how to do this with a if statement. I dont know how to tell it that the values are correct.. this is the code i am using
Code:
Private Sub cmdAdd_Click()
strRepTree(j, 1) = cboSpecies.Text
If Val(txtAge) <> Int(Val(txtAge)) Or Not IsNumeric(txtAge) Then
MsgBox " Invalid Age"
txtAge = ""
Else
strRepTree(j, 2) = txtAge
End If
If Not IsNumeric(txtHeight) Or Val(txtHeight) < Val(txtBLC) Then
MsgBox "BLC value can not be greater than Height value "
txtHeight = ""
Else
strRepTree(j, 3) = txtHeight
End If
If Not IsNumeric(txtBLC) Then
MsgBox "Enter correct BLC value"
txtBLC = ""
Else
strRepTree(j, 4) = txtBLC
End If
If Not IsNumeric(txtDia) Then
MsgBox "Enter Correct Diameter"
txtDia = ""
Else
strRepTree(j, 5) = txtDia
End If
frmStandVolume.lstRepTreeSum.AddItem strRepTree(j, 1) & "," & strRepTree(j, 2) & "," & strRepTree(j, 3) & "," & strRepTree(j, 4) & "," & strRepTree(j, 5)
j = j + 1
'****************** This is where I believe my if statements needs to go to see if all the numbers are correct*************
intRepTreeRecs = j - 1
optHwd.Value = False
optSwd.Value = False
cboSpecies.Clear
txtAge = ""
txtHeight = ""
txtBLC = ""
txtDia = ""
Comment