I'm fairly new to object-oriented programming, and am trying to implement a simple class in my VBA code in an attempt to move away from procedural based coding. Here's the set-up. I defined a class called cFormOps as follows:
Expand|Select|Wrap|Line Numbers
- Option Compare Database
- Option Explicit
- Implements IFormOps
- Private Sub IFormOps_ClearForm(frm As Form)
- Dim ctl As Control
- For Each ctl In frm.Controls
- If ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox Then
- ctl.SetFocus
- ctl.Text = ""
- End If
- Next
- End Sub
Expand|Select|Wrap|Line Numbers
- Option Compare Database
- Option Explicit
- Public Sub ClearForm(frm As Form): End Sub
Expand|Select|Wrap|Line Numbers
- Private Sub cmdClear_Click()
- Dim cMyFormOps As cFormOps
- Dim iMyFormOps As IFormOps
- Set cMyFormOps = New cFormOps
- Set iMyFormOps = cMyFormOps
- iMyFormOps.ClearForm Me
- End Sub
In VB .NET, I know there's even a way to use class functionality without having to instantiate the class. Is that possible in VBA? Thanks.
Pat