Stupid Scoping Problem?

G

Guest

I've got two files
Action.vb

Public Class Actio
Private _Type As Strin
Public Property Type() As Strin
Ge
Return _Typ
End Ge
Set(ByVal Value As String
_Type = Valu
End Se
End Propert
End Clas

and Complaint.vb

Public Class Complain
Private _ComplaintNumber As Strin
Public Property ComplaintNumber() As Strin
Ge
Return _ComplaintNumbe
End Ge
Set(ByVal Value As String
_ComplaintNumber = Valu
End Se
End Propert
Public Sub New(
'default constructo
End Su

Public Class ActionsLis
Inherits System.Collections.CollectionBas
Default Public ReadOnly Property Item(ByVal Index As Integer
Ge
Return CType(list.Item(Index), Action
End Ge
End Propert
Public Sub Add(ByVal SingleAction As Action
list.Add(SingleAction
End Su
End Clas

End Clas

When I try to us
Dim MyComplaint As New Complain
Dim MyAction As Actio
MyComplaint.ActionsList.Add(MyAction

I don't get any intellisense from VS after MyComplaint.ActionsList and the IDE gives me "Reference to a non-shared member requires an object reference"

Any ideas?
 
W

Wardeaux

Dave,
Looks like in class "Complaint" you specify the class "ActionsList" but do
not create an instance of the "ActionsList" class... you'll want to do that
in the Complaint constructor. (additionally you'll likely get a similar
error when you try to "...add(MyAction)" because you do not have an instance
of the "Action" class yet, you will need to "Dim MyAction as new Action()")

wardeaux

Dave said:
I've got two files
Action.vb

Public Class Action
Private _Type As String
Public Property Type() As String
Get
Return _Type
End Get
Set(ByVal Value As String)
_Type = Value
End Set
End Property
End Class

and Complaint.vb


Public Class Complaint
Private _ComplaintNumber As String
Public Property ComplaintNumber() As String
Get
Return _ComplaintNumber
End Get
Set(ByVal Value As String)
_ComplaintNumber = Value
End Set
End Property
Public Sub New()
'default constructor
End Sub

Public Class ActionsList
Inherits System.Collections.CollectionBase
Default Public ReadOnly Property Item(ByVal Index As Integer)
Get
Return CType(list.Item(Index), Action)
End Get
End Property
Public Sub Add(ByVal SingleAction As Action)
list.Add(SingleAction)
End Sub
End Class

End Class

When I try to use
Dim MyComplaint As New Complaint
Dim MyAction As Action
MyComplaint.ActionsList.Add(MyAction)

I don't get any intellisense from VS after MyComplaint.ActionsList and the
IDE gives me "Reference to a non-shared member requires an object reference"
 
G

Guest

Thanks...I must be missing something though because I can't figure out how to instantiate ActionList in the Complaint Constructor so I can see the ActionList.Add method.

----- Wardeaux wrote: -----

Dave,
Looks like in class "Complaint" you specify the class "ActionsList" but do
not create an instance of the "ActionsList" class... you'll want to do that
in the Complaint constructor. (additionally you'll likely get a similar
error when you try to "...add(MyAction)" because you do not have an instance
of the "Action" class yet, you will need to "Dim MyAction as new Action()")

wardeaux
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top