I want to loop through all my text boxes in my form and write a 0 (zero) in all those which don't have positive integers in them. Don't want any characters or negative numbers, only positive integers.
Thanks in advance
Thanks in advance
Dim ctrl As Control
For Each ctrl In Me.Controls
If TypeName(ctrl) = "TextBox" Then
If (Not (IsNumeric(ctrl.Value)) Or (ctrl.Value < 0)) Then
ctrl.Value = 0
End If
End If
Next ctrl
Dim ctrl As Control
For Each ctrl In Me.Controls
If TypeName(ctrl) = "TextBox" Then
If ctrl.Text = "" Then
ctrl.Text = 0
ElseIf (Not IsNumeric(ctrl.Text)) Then
ctrl.Text = 0
ElseIf (CInt(ctrl.Text) < 0) Then
ctrl.Text = 0
End If
End If
Next ctrl
Comment