|
之前在项目中写了这样一个VB.NET的方法,类似如下:
Function VerifyDate() As Boolean Dim flag As Boolean = True Dim a As Integer = 1 Dim b As Integer = 3 Dim c As Integer = 7 If b < c Then--验证1 Return flag = True Else Return flag = False End If If a > 0 Then--验证2 Return flag = False Else Return flag = False End If End Function
本来自已想达到的效果是:只有flag为False的时候,才会返回。可是程序在验证1为true的情况下,直接返回,没有验证第二个。最后我修改为如下:
Function VerifyDateNew() As Boolean Dim flag As Boolean = True Dim a As Integer = 1 Dim b As Integer = 3 Dim c As Integer = 7 If b >= c Then Return flag = False End If If a <= 0 Then Return flag = False End If End Function
这样的话,只有验证没有通过的话才会返回False值,这样不用担心会跳过后面的验证了。哎!难怪客户说“你们开发人员怎么会犯这么低级的错误”。我感觉好惭愧啊!我以后要好好对自已的程序负责了,对客户负责了。 (编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|