SET vs LET

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • peridian
    New Member
    • Dec 2006
    • 72

    #1

    SET vs LET

    Under VBA (and apparently VB6), when you create properties for class modules, you can use SET or LET depending on whether the variable in question is an object or not. However, this does not appear to be enforced in any way.

    What is the difference from an end result perspective?

    Code:
    Private myProperty As DAO.Recordset
    
    Public Property Let MyLetProp(newObject As DAO.Recordset)
      Set myProperty = newObject
    End Property
    
    Public Property Set MySetProp(newObject As DAO.Recordset)
      Set myProperty = newObject
    End Property
    
    Public Sub PrintOut()
        Call MsgBox("Records = " & myProperty.RecordCount, vbOKOnly, "Output")
    End Sub
    Code:
    Private Sub Run()
        Dim myClass As Class1
        Dim myDAO As DAO.Recordset
    
        Set myClass = New Class1
    
        Set myDAO = CurrentDb.OpenRecordset("DefMsgStart")
    
        Set myClass.MySetProp = myDAO
    
        Call myClass.PrintOut
    
        myClass.MyLetProp = myDAO
        
        Call myClass.PrintOut
    End Sub
    Edit Forgot a line.
Working...