473,382 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Stupid Scoping Problem?

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?

Nov 18 '05 #1
3 893
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" <an*******@discussions.microsoft.com> wrote in message
news:DF**********************************@microsof t.com...
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"
Any ideas?

Nov 18 '05 #2
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

"Dave" <an*******@discussions.microsoft.com> wrote in message
news:DF**********************************@microsof t.com...
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" Any ideas?

Nov 18 '05 #3
Thanks guys...that did it.
Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: David Stockwell | last post by:
Hi, Another of my crazy questions. I'm just in the process of learning so bear with me if you can. I actually ran it.... with two test cases TEST CASE 1: Say I have the following defined:...
4
by: Frederick Grim | last post by:
okay so the code in question looks like: namespace util { template<typename C> inline void mmapw(C *& ptr, size_t length, int prot, int flags, int fd, off_t offset) { if((ptr =...
3
by: Robert | last post by:
Greetings I have been trying to write a script that will list out the size of each user table in a specified DB. I am running into a scoping problem when trying to format my display. I am sure...
1
by: Michael | last post by:
I am having a problem with scoping of parameters in my XSLT Stylesheet...here is the stylesheet (the xml document is irrelevant for the example) <?xml version="1.0" encoding="UTF-8"?>...
4
by: Joel Gordon | last post by:
Hi, When I try and compile the a class containing the following method : public void doSomething() { for (int i=0; i<5; i++) { IList list = new ArrayList(); Console.WriteLine( i /...
9
by: NevilleDNZ | last post by:
Can anyone explain why "begin B: 123" prints, but 456 doesn't? $ /usr/bin/python2.3 x1x2.py begin A: Pre B: 123 456 begin B: 123 Traceback (most recent call last): File "x1x2.py", line 13,...
3
by: morris.slutsky | last post by:
So every now and then I like to mess around with hobby projects - I often end up trying to write an OpenGL video game. My last attempt aborted due to the difficulty of automating game elements and...
17
by: Chad | last post by:
The following question stems from Static vs Dynamic scoping article in wikipedia. http://en.wikipedia.org/wiki/Scope_(programming)#Static_versus_dynamic_scoping Using this sites example, if I...
3
by: SPECTACULAR | last post by:
Hi all. I have a question here.. what kind of scoping does C++ use? and what kind does Smalltalk use? I know smalltalk is a little bit old .. but any help would be appreciated.
1
by: shaneal | last post by:
Hello all, I've been trying to learn some javascript and I ran into a strange scoping problem I was hoping someone here could help with. I have a fair amount of experience with functional...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.