So why did the "FirstName" did not show up in the listbox? It became already clear during the demonstration that it had nothing to do with the listbox, since the combo box also did not produce the intended results either.
As I figured out shortly after the class ended, the problem was not related to the code in the event handler routine nor the form frmStart in my smartDemoApp at all. The problem lies with the Person class declaration. Since we have not covered object-oriented programming and the concept of a class, my intention was to keep the design of the class as simple as possible, thus taking a shortcut.
All the class attributes , including "FirstName", were declared as simple Public attributes (as shown below).
Public Class Person
Public FirstName As String
Public LastName As String
Public SSN As String
End Class
They should really have been declared as Public Properties instead. Usually it is considered good class design to make all attributes of a class private and use the property mechanism to expose them externally. As it is evident in the complete class declaration below, this makes the whole class declaration quite a bit longer and more complex.
Public Class Person
Private _firstName As String
Private _lastName As String
Private _ssn As String
Public Property FirstName() As String
Get
Return _firstName
End Get
Set(ByVal value As String)
_firstName = value
End Set
End Property
Public Property LastName() As String
Get
Return _lastName
End Get
Set(ByVal value As String)
_lastName = value
End Set
End Property
Public Property SSN() As String
Get
Return _ssn
End Get
Set(ByVal value As String)
_ssn = value
End Set
End Property
End Class
So why did I think that my shortcut (not using properties) would work in the first place?
This relates back to Web services ... which is also beyond what we have covered so far in class.
A simplified Person class without using properties would have worked, if used in the context of a Web service. It comes down to the fact that Web services are not distributed objects, and the distinction between a property and a public attribute disappears, when a class is exposed via a Web service ... everything becomes a property.
I guess I have been doing a few too many Web service projects lately 
So my lessons out of this failed demonstration are:
1) Only properties will be recognized as a display or value member
2) Web services are not distributed objects (and the distinction between an attribute and a property disappears)
3) Don't take shortcuts ... I need to read the story of the turtle and the hare again!
MH
P.S.,
You can download the code relating to the this demo from the G-drive (see course folder -> code -> smartDemoApp.zip)
Technorati : BUS ADM 740
Powered by Zoundry