Is “Value” actually the default property of the Range object?

前端 未结 2 960
孤城傲影
孤城傲影 2020-11-28 14:43

Before I begin I want to say that I realize you should never depend on default properties and I won\'t, but this is curious. I\'ve always read that value is th

2条回答
  •  南方客
    南方客 (楼主)
    2020-11-28 15:34

    Yes, it appears that Value is default property of Range.

    I put a very large number in cell A1.

    Sub Test()
        Debug.Print "Range default = " & Range("A1") & vbCrLf _
            & "Range Text = " & Range("A1").Text & vbCrLf _
            & "Range Value = " & Range("A1").Value & vbCrLf _
            & "Range Value2 = " & Range("A1").Value2
    End Sub
    
    Results in 
    
    Range default = 3.24643541346456E+28
    Range Text = 3.25E+28
    Range Value = 3.24643541346456E+28
    Range Value2 = 3.24643541346456E+28
    

    Notice that Range("A1")'s result is identical to Range("A1").Value and Range("A1").Value2

提交回复
热议问题