Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can i check 4 things with one "If statement" and using for all the same msgbox...


here is the code: For VS2012 can't use and &&, or ||...What can i use?

VB
If (Form2.txtName.Text ="" Form2.txtLastName.Text = "" Form2.cboField.Text = 0 Form2.cboStudy.Text = 0) Then
           MsgBox("Fill all your information please")
       End If
Posted

And[^] / AndAlso[^]
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 18-Jan-13 19:34pm    
Right, a 5. Will OP understand the difference? "AndAlso" optimized out redundant check, but if condition calls some functions with side effect, such optimization will get this side effect lost, which can be a problem.
—SA
If you are writing in VB.NET, the keywords are
VB
AndAlso
(equivalent to C# double ampersand) and
VB
OrElse
(equivalent to C# double pipe).

VB
If (Form2.txtName.Text ="" OrElse Form2.txtLastName.Text = "" OrElse Form2.cboField.Text = 0 OrElse Form2.cboStudy.Text = 0) Then
           MsgBox("Fill all your information please")
       End If


You should also use String.IsNullOrEmpty() to check if a string is null or an empty string ("").
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 18-Jan-13 19:34pm    
Right, a 5. But will OP understand the difference? "AndAlso" optimized out redundant check, but if condition calls some functions with side effect, such optimization will get this side effect lost, which can be a problem.
—SA
San Dra 19-Jan-13 6:52am    
It worked with "OrElse"..so that's for Visual Studio 2012 in vb..:))

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900