如果声明Visual Studio 2012 [英] If statement Visual studio 2012

查看:116
本文介绍了如果声明Visual Studio 2012的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用一个If语句检查4件事并使用相同的msgbox ...





这里是代码:对于VS2012不能使用&&,或者|| ...我可以使用什么?



 如果(Form2.txtName.Text =    Form2.txtLastName.Text =   Form2.cboField.Text =  0  Form2.cboStudy.Text =  0 然后 
MsgBox( 请填写所有信息
结束 如果

解决方案

[ ^ ] / AndAlso [ ^ ]


如果您使用VB.NET编写,关键字是

  AndAlso  

(相当于C#double&符号)和

  OrElse  

(相当于C#双管道) 。



 如果(Form2.txtName.Text =    OrElse  Form2.txtLastName.Text =    OrElse  Form2.cboField.Text = < span class =code-digit> 0   OrElse  Form2.cboStudy.Text =  0 然后 
MsgBox( 请填写所有信息
结束 如果





您还应该使用String.IsNullOrEmpty()来检查字符串是空还是空字符串()。


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?

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

解决方案

And[^] / AndAlso[^]


If you are writing in VB.NET, the keywords are

AndAlso

(equivalent to C# double ampersand) and

OrElse

(equivalent to C# double pipe).

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 ("").


这篇关于如果声明Visual Studio 2012的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆