PDA

View Full Version : Vb Code To VBA



sconly
06-04-2014, 09:34 AM
I would very much appreciate it if someone could help me with converting the VB 2010 code below to Access 2010 VBA

Public Class CustomerList
Private mCustName As String
Private mCustID As Integer

Public Sub New(ByVal pText As String, ByVal pValue As Integer)
mCustName = pText
mCustID = pValue
End Sub

Public ReadOnly Property CustName() As String
Get
Return mCustName
End Get
End Property

Public ReadOnly Property CustID() As Integer
Get
Return mCustID
End Get
End Property

Public Overrides Function ToString() As String
Return mCustName
End Function

End Class

What it does, in VB 2010, is store the customer name and ID so that when the customer name is selected in a combobox you can use the CustomerID to pass to a SQL stored procedure.

Thanks

ranman256
06-04-2014, 12:28 PM
We dont use 'Get' (.net).
Access combos get data from tables/qrys.
The queries then reference the combo val...no need for modular variables.

it would be: forms!frmMain!cboCust
but for a Class, you need to view old VB6 version of class assigned module level variables.

ranman256
06-04-2014, 12:32 PM
Public Property Get Subject() As Variant
Subject = mvSubject
End Property

Public Property Let Subject(ByVal vNewValue As Variant)
mvSubject = vNewValue
End Property