Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7592125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:49:42+00:00 2026-05-30T20:49:42+00:00

Ive got a Form application in VB.NET. I have many text boxes on one

  • 0

Ive got a Form application in VB.NET.

I have many text boxes on one form (about 20). Is there anyway to check them all at once to see if they are empty instead of writing out a massive line of code to check each one individually such as

If txt1.text = "" Or txt2.text="" Then
    msgbox("Please fill in all boxes")

That just seems like a long way around it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T20:49:43+00:00Added an answer on May 30, 2026 at 8:49 pm

    You could also use LINQ:

    Dim empty =
        Me.Controls.OfType(Of TextBox)().Where(Function(txt) txt.Text.Length = 0)
    If empty.Any Then
        MessageBox.Show(String.Format("Please fill following textboxes: {0}",
                        String.Join(",", empty.Select(Function(txt) txt.Name))))
    End If
    

    The interesting method is Enumerable.OfType

    The same in query syntax(more readable in VB.NET):

    Dim emptyTextBoxes =
        From txt In Me.Controls.OfType(Of TextBox)()
        Where txt.Text.Length = 0
        Select txt.Name
    If emptyTextBoxes.Any Then
        MessageBox.Show(String.Format("Please fill following textboxes: {0}",
                        String.Join(",", emptyTextBoxes)))
    End If
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ive got ASP.NET web application form where users enter details such as: Subject Code
So on my application login form I've got one of those little boxes like
I've got a VB.Net form application that dynamically loads user controls based on which
I've got a Windows Forms application with two ListBox controls on the same form.
I've got a form where I have two radio buttons and two interchangeable controls
I've got an ASP.NET web application, and I'm attempting to reduce HTTP calls to
I've got an ASP.NET 3.5 Web Forms application in which a large chunk of
Title is pretty self-explanatory. I've got a DataGrid for a Windows Form Application, and
I've got a form in a 24/7 application that will probably be needed as
I've got a .NET MDI (multiple document interface) application that I want to use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.