DateTime变量在Visual Basic中设置为等于它自己

时间:2015-12-07 15:12:35

标签: vb.net

有没有理由为什么有人会在Visual Basic中设置一个等于自身的DateTime变量,如下面的代码中的dtLocDate?

Function ShouldBillingStart(ByVal sTheBillingType As String, _
  ByRef bStartIt As Boolean, _
  ByVal dtBillPeriod As DateTime) As Boolean

    Dim bLocResult As Boolean
    Dim dtFirstOfMonth As DateTime
    Dim dtLocDate As DateTime

    bLocResult = True
    bStartIt = True
    If bLocResult = True Then
        If CInt(sTheBillingType) = gTheMasterPriceList.PricingType.PRICING_TYPE_DISCOUNTED Then
            dtLocDate = dtLocDate
            dtFirstOfMonth = CDate(Year(dtLocDate) & "/" & Month(dtLocDate) & "/1")
            'add a month
            dtFirstOfMonth = DateAdd(DateInterval.Month, 1, dtFirstOfMonth)
            If Now < dtFirstOfMonth Then
                bStartIt = False
            End If
        End If
    End If

    ShouldBillingStart = bLocResult
End Function

2 个答案:

答案 0 :(得分:1)

简而言之,没有。这只是引用自己。 Dim语句实例化Date对象。自引用它不会创建对象,也不会设置默认值。

这似乎没有用处。

答案 1 :(得分:1)

是的,完全没有理由。例如:

Dim This as String

This = "that"
This = This

浪费时间&amp;资源...

相关问题