Permalink

Good one, i was trying almost the same thing but including an errorProvider to avoid message Box popping for every error and likely annoying the user.. So please review the code below and advise why this doesnt always show the errorProvder when there is no input

   Dim isValid As Boolean = False
        For Each c As Control In Me.TableLayoutPanel1.Controls
            If TypeOf c Is TextBox Then
                If (CType(c, TextBox).Text.Trim() = String.Empty) Then
                    ErrorProvider1.SetError(c, "Required field.")
                    isValid = False
                    Exit For
                Else 'If (CType(c, TextBox).Text.Trim()  String.Empty) Then
                    ErrorProvider1.SetError(c, "")
                    isValid = True
                    Continue For
                End If
            End If
        Next
        Return isValid
The content of this field is kept private and will not be shown publicly.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.