Hello all,
I have a form with 24 textboxes incremented by a letter.
example: txtDimVala1.text, txtDimValb1.text, txtDimValc1.text, etc.
I created a code to check each textbox, but there must me a more efficient way to loop it. I have tried a few loops but I cant get them to work looping through the different textbox values.
Thanks for any help in advance.
below is the code i already have
Private Sub CheckDims()
If (IsNumeric(txtDimVala1.Text)) Then
Dim num As Decimal = txtDimVala1.Text
Dim num2 As Decimal = txtDimL1.Text
Dim num3 As Decimal = txtDimU1.Text
If num < num2 Or num > num3 Then
txtDimVala1.BackColor = Color.LightSalmon
Else
txtDimVala1.BackColor = Color.White
End If
End If
If (IsNumeric(txtDimValb1.Text)) Then
Dim num As Decimal = txtDimValb1.Text
Dim num2 As Decimal = txtDimL1.Text
Dim num3 As Decimal = txtDimU1.Text
If num < num2 Or num > num3 Then
txtDimValb1.BackColor = Color.LightSalmon
Else
txtDimValb1.BackColor = Color.White
End If
End If
If (IsNumeric(txtDimValc1.Text)) Then
Dim num As Decimal = txtDimValc1.Text
Dim num2 As Decimal = txtDimL1.Text
Dim num3 As Decimal = txtDimU1.Text
If num < num2 Or num > num3 Then
txtDimValc1.BackColor = Color.LightSalmon
Else
txtDimValc1.BackColor = Color.White
End If
End If
If (IsNumeric(txtDimVald1.Text)) Then
Dim num As Decimal = txtDimVald1.Text
Dim num2 As Decimal = txtDimL1.Text
Dim num3 As Decimal = txtDimU1.Text
If num < num2 Or num > num3 Then
txtDimVald1.BackColor = Color.LightSalmon
Else
txtDimVald1.BackColor = Color.White
End If
End If
If (IsNumeric(txtDimVale1.Text)) Then
Dim num As Decimal = txtDimVale1.Text
Dim num2 As Decimal = txtDimL1.Text
Dim num3 As Decimal = txtDimU1.Text
If num < num2 Or num > num3 Then
txtDimVale1.BackColor = Color.LightSalmon
Else
txtDimVale1.BackColor = Color.White
End If
End If
If (IsNumeric(txtDimValf1.Text)) Then
Dim num As Decimal = txtDimValf1.Text
Dim num2 As Decimal = txtDimL1.Text
Dim num3 As Decimal = txtDimU1.Text
If num < num2 Or num > num3 Then
txtDimValf1.BackColor = Color.LightSalmon
Else
txtDimValf1.BackColor = Color.White
End If
End If
If (IsNumeric(txtDimValg1.Text)) Then
Dim num As Decimal = txtDimValg1.Text
Dim num2 As Decimal = txtDimL1.Text
Dim num3 As Decimal = txtDimU1.Text
If num < num2 Or num > num3 Then
txtDimValg1.BackColor = Color.LightSalmon
Else
txtDimValg1.BackColor = Color.White
End If
End If
If (IsNumeric(txtDimValh1.Text)) Then
Dim num As Decimal = txtDimValh1.Text
Dim num2 As Decimal = txtDimL1.Text
Dim num3 As Decimal = txtDimU1.Text
If num < num2 Or num > num3 Then
txtDimValh1.BackColor = Color.LightSalmon
Else
txtDimValh1.BackColor = Color.White
End If
End If
If (IsNumeric(txtDimVali1.Text)) Then
Dim num As Decimal = txtDimVali1.Text
Dim num2 As Decimal = txtDimL1.Text
Dim num3 As Decimal = txtDimU1.Text
If num < num2 Or num > num3 Then
txtDimVali1.BackColor = Color.LightSalmon
Else
txtDimVali1.BackColor = Color.White
End If
End If
If (IsNumeric(txtDimValj1.Text)) Then
Dim num As Decimal = txtDimValj1.Text
Dim num2 As Decimal = txtDimL1.Text
Dim num3 As Decimal = txtDimU1.Text
If num < num2 Or num > num3 Then
txtDimValj1.BackColor = Color.LightSalmon
Else
txtDimValj1.BackColor = Color.White
End If
End If
If (IsNumeric(txtDimValk1.Text)) Then
Dim num As Decimal = txtDimValk1.Text
Dim num2 As Decimal = txtDimL1.Text
Dim num3 As Decimal = txtDimU1.Text
If num < num2 Or num > num3 Then
txtDimValk1.BackColor = Color.LightSalmon
Else
txtDimValk1.BackColor = Color.White
End If
End If
If (IsNumeric(txtDimVall1.Text)) Then
Dim num As Decimal = txtDimVall1.Text
Dim num2 As Decimal = txtDimL1.Text
Dim num3 As Decimal = txtDimU1.Text
If num < num2 Or num > num3 Then
txtDimVall1.BackColor = Color.LightSalmon
Else
txtDimVall1.BackColor = Color.White
End If
End If
If (IsNumeric(txtDimValm1.Text)) Then
Dim num As Decimal = txtDimValm1.Text
Dim num2 As Decimal = txtDimL1.Text
Dim num3 As Decimal = txtDimU1.Text
If num < num2 Or num > num3 Then
txtDimValm1.BackColor = Color.LightSalmon
Else
txtDimValm1.BackColor = Color.White
End If
End If
If (IsNumeric(txtDimValn1.Text)) Then
Dim num As Decimal = txtDimValn1.Text
Dim num2 As Decimal = txtDimL1.Text
Dim num3 As Decimal = txtDimU1.Text
If num < num2 Or num > num3 Then
txtDimValn1.BackColor = Color.LightSalmon
Else
txtDimValn1.BackColor = Color.White
End If
End If
If (IsNumeric(txtDimValo1.Text)) Then
Dim num As Decimal = txtDimValo1.Text
Dim num2 As Decimal = txtDimL1.Text
Dim num3 As Decimal = txtDimU1.Text
If num < num2 Or num > num3 Then
txtDimValo1.BackColor = Color.LightSalmon
Else
txtDimValo1.BackColor = Color.White
End If
End If
If (IsNumeric(txtDimValp1.Text)) Then
Dim num As Decimal = txtDimValp1.Text
Dim num2 As Decimal = txtDimL1.Text
Dim num3 As Decimal = txtDimU1.Text
If num < num2 Or num > num3 Then
txtDimValp1.BackColor = Color.LightSalmon
Else
txtDimValp1.BackColor = Color.White
End If
End If
If (IsNumeric(txtDimValq1.Text)) Then
Dim num As Decimal = txtDimValq1.Text
Dim num2 As Decimal = txtDimL1.Text
Dim num3 As Decimal = txtDimU1.Text
If num < num2 Or num > num3 Then
txtDimValq1.BackColor = Color.LightSalmon
Else
txtDimValq1.BackColor = Color.White
End If
End If
If (IsNumeric(txtDimValr1.Text)) Then
Dim num As Decimal = txtDimValr1.Text
Dim num2 As Decimal = txtDimL1.Text
Dim num3 As Decimal = txtDimU1.Text
If num < num2 Or num > num3 Then
txtDimValr1.BackColor = Color.LightSalmon
Else
txtDimValr1.BackColor = Color.White
End If
End If
If (IsNumeric(txtDimVals1.Text)) Then
Dim num As Decimal = txtDimVals1.Text
Dim num2 As Decimal = txtDimL1.Text
Dim num3 As Decimal = txtDimU1.Text
If num < num2 Or num > num3 Then
txtDimVals1.BackColor = Color.LightSalmon
Else
txtDimVals1.BackColor = Color.White
End If
End If
If (IsNumeric(txtDimValt1.Text)) Then
Dim num As Decimal = txtDimValt1.Text
Dim num2 As Decimal = txtDimL1.Text
Dim num3 As Decimal = txtDimU1.Text
If num < num2 Or num > num3 Then
txtDimValt1.BackColor = Color.LightSalmon
Else
txtDimValt1.BackColor = Color.White
End If
End If
If (IsNumeric(txtDimValu1.Text)) Then
Dim num As Decimal = txtDimValu1.Text
Dim num2 As Decimal = txtDimL1.Text
Dim num3 As Decimal = txtDimU1.Text
If num < num2 Or num > num3 Then
txtDimValu1.BackColor = Color.LightSalmon
Else
txtDimValu1.BackColor = Color.White
End If
End If
If (IsNumeric(txtDimValv1.Text)) Then
Dim num As Decimal = txtDimValv1.Text
Dim num2 As Decimal = txtDimL1.Text
Dim num3 As Decimal = txtDimU1.Text
If num < num2 Or num > num3 Then
txtDimValv1.BackColor = Color.LightSalmon
Else
txtDimValv1.BackColor = Color.White
End If
End If
If (IsNumeric(txtDimValw1.Text)) Then
Dim num As Decimal = txtDimValw1.Text
Dim num2 As Decimal = txtDimL1.Text
Dim num3 As Decimal = txtDimU1.Text
If num < num2 Or num > num3 Then
txtDimValw1.BackColor = Color.LightSalmon
Else
txtDimValw1.BackColor = Color.White
End If
End If
If (IsNumeric(txtDimValx1.Text)) Then
Dim num As Decimal = txtDimValx1.Text
Dim num2 As Decimal = txtDimL1.Text
Dim num3 As Decimal = txtDimU1.Text
If num < num2 Or num > num3 Then
txtDimValx1.BackColor = Color.LightSalmon
Else
txtDimValx1.BackColor = Color.White
End If
End If
If (IsNumeric(txtDimValy1.Text)) Then
Dim num As Decimal = txtDimValy1.Text
Dim num2 As Decimal = txtDimL1.Text
Dim num3 As Decimal = txtDimU1.Text
If num < num2 Or num > num3 Then
txtDimValy1.BackColor = Color.LightSalmon
Else
txtDimValy1.BackColor = Color.White
End If
End If
End Sub