Hello masters,

I want to know how to check an empty textbox in the form.
I can check it by assign Text1.Text = "".
But i have many textbox in form.

Thank you in advance

Recommended Answers

All 2 Replies

Try this :

Dim ctrAs Control

For Each ctr In Me.Controls
   If TypeOf ctr Is TextBox Then
      If ctr.Text= vbNullString Then
         MsgBox "Textbox empty"

         ctr.SetFocus

         Exit Sub

      End If
  End If
Next ctr
commented: Excellent suggestions based on in depth knowledge of the language. +5
commented: It's a wonderful code sir :) +2

Thank you sir for wonderful code..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.