Proper way of using this password

What is the shortest way to make  this code functional?
Private sub Command1_Click()
if text1. text or text2.text or text3.text or text4.text = "" then
msgbox "Good"
else
Msgbox "Okey"
exit sub
end if

Open in new window

Whing Dela CruzAsked:
Who is Participating?
 
Éric MoreauSenior .Net ConsultantCommented:
You will need to compare one by one:
Private sub Command1_Click()
if text1.text = "" then
msgbox "Good - text1 is empty"
elseif text2.text = "" then
msgbox "Good - text2 is empty"
elseif text3.text = "" then
msgbox "Good - text3 is empty"
elseif text4.text = "" then
msgbox "Good - text4 is empty"
else
Msgbox "Okey"
exit sub
end if

Open in new window

0
 
Éric MoreauSenior .Net ConsultantCommented:
you cannot compare the same value against multiple controls like this.

you have to do this:

Private sub Command1_Click()
if text1.text = "" or text2.text = "" or text3.text = "" or text4.text = "" then
msgbox "Good"
else
Msgbox "Okey"
exit sub
end if

Open in new window

0
 
Whing Dela CruzAuthor Commented:
Thanks emoreau it works..
in this procedure, Can i make a msgbox that will specify or tells which of the textbox is blank?
example a message says like this
text2.text is blank
thanks...
0
 
Whing Dela CruzAuthor Commented:
Thanks emoreau, it works ...
More Power to you....
Please see my other post questions...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.