JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Creating Data Members

As discussed in the In Depth section of this chapter, the fields of a class, also called the class's data members, are much like built-in variables. For example, in the In Depth section of this chapter, I declared a field named value in a class named DataClass:

Public Class DataClass
    Public value As Integer
End Class

Now I can refer to that field in an object of this class using the familiar object.field syntax of Visual Basic:

Dim data As New DataClass()
data.value = 5

You also can make fields hold constant values with Const:

Public Class Class1
    Public Const Field1 As Integer = 0
        
End Class

These data members are object data members—you use them with a specific object. However, you also can create class data members; see the next topic for the details.

Related solution:

Found on page:

Declaring Variables

73

Previous Section Next Section




JavaScript Editor Free JavaScript Editor     JavaScript Editor